Skip to main content

BB_Strategy04 Strategy In-Depth Analysis

Strategy Number: #454 (454th out of 465 strategies)
Strategy Type: Double Standard Deviation Bollinger Bands Breakout Strategy
Timeframe: 1 hour (1h)


1. Strategy Overview

BB_Strategy04 is a breakout strategy based on double standard deviation Bollinger Bands. The strategy uses 72-period (approximately 3 days) Bollinger Bands, simultaneously calculating 1 standard deviation and 2 standard deviation channels, buying when price touches near the 2 standard deviation lower band, and selling when price breaks through the 2 standard deviation upper band.

Core Features

FeatureDescription
Buy Conditions1 independent buy signal (Near 2 std dev lower band)
Sell Conditions1 base sell signal (2 std dev upper band breakout)
Protection MechanismsLoose stoploss (-32.5%) + Trailing stoploss
Timeframe1 hour
Dependenciestalib, qtpylib, numpy, pandas

2. Strategy Configuration Analysis

2.1 Base Risk Parameters

# ROI exit table
minimal_roi = {
"0": 0.22597784040439192, # Immediate 22.6% profit
"180": 0.06269048445164815, # 6.27% profit after 180 minutes
"613": 0.037662786960331776, # 3.77% profit after 613 minutes
"2004": 0 # Break-even exit after 2004 minutes
}

# Stoploss settings
stoploss = -0.32530922906811843 # Fixed stoploss -32.5%

# Trailing stoploss
trailing_stop = True
# trailing_only_offset_is_reached = False # Not configured
# trailing_stop_positive = 0.01 # Not configured
# trailing_stop_positive_offset = 0.0 # Not configured

Design Rationale:

  • ROI table parameters are precise to multiple decimal places, obviously经过 hyperparameter optimization
  • Fixed stoploss around 32.5%, extremely loose, allows significant drawdown
  • Trailing stoploss enabled but parameters not finely configured

2.2 Order Type Configuration

order_types = {
'buy': 'limit', # Limit buy
'sell': 'limit', # Limit sell
'stoploss': 'market', # Market stoploss
'stoploss_on_exchange': False
}

order_time_in_force = {
'buy': 'gtc', # Good Till Cancelled
'sell': 'gtc'
}

3. Buy Conditions Explained

3.1 Single Buy Condition

The strategy employs a simple single-condition buy logic:

dataframe.loc[
(
(dataframe['close'] < dataframe['bb_lowerband2']) # Close below 2 std dev lower band
&
(dataframe['close'] > dataframe['bb_lowerband2'] * (1 + self.stoploss)) # But not below stoploss position
),
'buy'] = 1

Logic Breakdown:

ConditionMeaningDesign Intent
close < bb_lowerband2Price breaks below 2 std dev lower bandCapture extreme oversold opportunities
close > bb_lowerband2 * (1 + stoploss)Price not below lower band × (1 - 32.5%)Avoid entering during extreme crashes

Buy Zone Illustration:

Price Position Illustration:

bb_upperband2 ← 2σ Upper Band
─────────────────

bb_upperband1 ← 1σ Upper Band
─────────────────

bb_middleband ← Middle Band

─────────────────
bb_lowerband1 ← 1σ Lower Band

─────────────────
bb_lowerband2 ← 2σ Lower Band

│ ★ Buy Zone
│ (Price below 2σ lower band but above lower band × 67.5%)

✗ Do Not Buy (Decline exceeds stoploss line)

3.2 Bollinger Bands Parameters

# Bollinger Bands parameters
window = 24 * 3 # 72 periods (approximately 3 days, for 1h timeframe)
stds = [1, 2] # Calculate 1 std dev and 2 std dev

Parameter Interpretation:

  • 72 periods: Approximately 3 days of data, filters short-term noise
  • Double Standard Deviation: 1σ for visual reference, 2σ for trading signals
  • Uses Close Price: Not typical price, simplifies calculation

4. Sell Logic Explained

4.1 Single Sell Signal

dataframe.loc[
(
(dataframe['close'] > dataframe['bb_upperband2']) # Close above 2 std dev upper band
),
'sell'] = 1

Logic Interpretation:

ConditionMeaningDesign Intent
close > bb_upperband2Price breaks above 2 std dev upper bandCapture exit opportunity after extreme overbought

4.2 ROI Time Decay Mechanism

Holding TimeTarget ReturnNotes
0 minutes22.60%High return target immediately after opening
180 minutes (3 hours)6.27%Reduce return expectations
613 minutes (~10.2 hours)3.77%Continue reducing
2004 minutes (~33.4 hours)0%Break-even exit

Design Intent: Stepwise reduction of profit targets, avoids long-term holding.

4.3 Multi-Layer Exit Mechanism

Exit Priority: ROI → Trailing Stoploss → Fixed Stoploss → Signal Sell

1. ROI Exit: Decreasing profit targets based on holding time
2. Trailing Stoploss: Enabled but default parameters
3. Fixed Stoploss: Forced exit when loss exceeds 32.5%
4. Signal Sell: Price breaks above 2σ upper band

5. Technical Indicator System

5.1 Core Indicators

Indicator CategorySpecific IndicatorParametersUsage
Trend IndicatorBollinger Bands (BB) - 1σ72 periods, 1 std devVisual reference
Trend IndicatorBollinger Bands (BB) - 2σ72 periods, 2 std devTrading signals
Momentum IndicatorRelative Strength Index (RSI)Default 14 periodsCalculated (not used for signals)

5.2 Indicator Calculation Code

# RSI calculation (calculated but not used for signals)
dataframe['rsi'] = ta.RSI(dataframe)

# Double standard deviation Bollinger Bands calculation
for std in [1, 2]:
bollinger = qtpylib.bollinger_bands(
dataframe['close'],
window=24*3, # 72 periods
stds=std
)
dataframe[f'bb_lowerband{std}'] = bollinger['lower']
dataframe[f'bb_middleband{std}'] = bollinger['mid']
dataframe[f'bb_upperband{std}'] = bollinger['upper']

5.3 Visualization Configuration

plot_config = {
'main_plot': {
'bb_lowerband2': {'color': 'red'}, # 2σ lower band - red
'bb_lowerband1': {'color': 'green'}, # 1σ lower band - green
'bb_middleband1': {'color': 'orange'}, # Middle band - orange
'bb_upperband1': {'color': 'green'}, # 1σ upper band - green
}
}

6. Risk Management Features

6.1 Extremely Loose Stoploss Settings

The strategy employs a fixed stoploss of approximately 32.5%, which is an extremely loose setting:

Risk Control TypeParameterDescription
Fixed Stoploss-32.5%Allows significant drawdown
Trailing StoplossEnabledParameters not finely configured

Risk Assessment:

  • Advantage: Gives the strategy ample "breathing room", won't be shaken out by short-term volatility
  • Risk: Single-trade loss can be extremely large, requires strict position management

6.2 ROI Parameter Characteristics

ROI table parameters are precise to 8-14 decimal places, indicating fine hyperparameter optimization:

"0": 0.22597784040439192      # Precise to 14 decimal places
"180": 0.06269048445164815 # Precise to 14 decimal places
"613": 0.037662786960331776 # Precise to 15 decimal places

Over-optimization Risk: Such precise parameters may be overfitting to historical data, live trading performance may differ significantly from backtesting.

6.3 Buy Protection Mechanism

dataframe['close'] > dataframe['bb_lowerband2'] * (1 + self.stoploss)

The actual meaning of this condition:

  • 1 + stoploss = 1 + (-0.325) = 0.675
  • That is: Price not below 67.5% of lower band
  • This is a "decline protection", avoids entering during extreme crashes

7. Strategy Strengths and Limitations

✅ Strengths

  1. Double Standard Deviation Channels: 2σ channels capture extreme deviations better than 1σ
  2. Loose Stoploss: Allows significant drawdown, won't be shaken out by normal volatility
  3. Long-period Bollinger Bands: 72 periods filters short-term noise
  4. Simple Logic: Single buy/sell conditions, easy to understand and maintain
  5. Buy Protection: Avoids entering during extreme crashes

⚠️ Limitations

  1. Suspected Over-optimization: ROI parameters precise to multiple decimal places, may be overfitted
  2. Stoploss Too Wide: 32.5% stoploss may lead to huge single-trade losses
  3. RSI Not Used: RSI is calculated but not used for trading signals
  4. Trailing Stoploss Not Configured: Enabled but default parameters, not finely tuned
  5. No Trend Filter: Does not judge major trend direction

8. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Range-bound MarketDefault configurationStrategy's original design
Slow Bull MarketLower stoplossCan appropriately tighten stoploss
Sharp DeclineUse with cautionWide stoploss may承受 large losses
High VolatilityAdjust Bollinger Bands parametersMay need wider channels

9. Applicable Market Environments Explained

BB_Strategy04 is an extreme mean reversion strategy. Using 2 standard deviation Bollinger Bands means it only enters when price shows extreme deviations. It is best suited for volatile range-bound markets and performs poorly in single-sided trend markets.

9.1 Strategy Core Logic

  • Extreme Deviation Capture: 2σ deviation means approximately 95% of prices fall within the channel, breaking 2σ is a low-probability event
  • Mean Reversion Expectation: Price tends to回归 mean after extreme deviations
  • Loose Stoploss: Gives strategy sufficient time to wait for regression

9.2 Performance in Different Market Environments

Market TypePerformance RatingReason Analysis
📈 Slow Bull Market⭐⭐☆☆☆May sell too early, miss gains
🔄 Range-bound Market⭐⭐⭐⭐⭐Best application scenario, captures extreme deviations
📉 Sharp Decline Market⭐☆☆☆☆Stoploss too wide, may承受 huge losses
⚡️ Single-sided Trend⭐☆☆☆☆Counter-trend operations carry extreme risk

9.3 Key Configuration Recommendations

Configuration ItemRecommended ValueDescription
Stoploss-15% ~ -20%Current setting too wide, recommend tightening
Timeframe1hKeep default
PositionSmall positionWide stoploss risk is high, need position control

10. Important Reminders: The Cost of Complexity

10.1 Learning Curve

The strategy logic is relatively simple, but understanding the statistical meaning of 2 standard deviation Bollinger Bands requires some foundation:

  • Understand normal distribution and standard deviation
  • Master the meaning of Bollinger Band channels
  • Understand the risks of mean reversion strategies

10.2 Hardware Requirements

Number of Trading PairsMinimum RAMRecommended RAM
1-10 pairs1GB2GB
10-50 pairs2GB4GB

Strategy computational requirements are low.

10.3 Differences Between Backtesting and Live Trading

Over-optimization Risk:

  • ROI parameters precise to 14 decimal places
  • Obviously the result of hyperparameter optimization
  • Live trading performance may differ significantly from backtesting

Recommendations:

  • Evaluate backtest results at 50-70% of reported performance
  • Test live trading with extremely small positions first
  • Consider simplifying ROI parameters

10.4 Recommendations for Manual Traders

If manually referencing this strategy:

  • Bollinger Bands parameters: 72 periods, 2 std dev
  • Buy condition: Price breaks below 2σ lower band
  • Sell condition: Price breaks above 2σ upper band
  • Stoploss: Recommend setting more reasonable stoploss (e.g., 15-20%)

11. Summary

BB_Strategy04 is a double standard deviation Bollinger Bands mean reversion strategy. Its core value lies in:

  1. Extreme Deviation Capture: Uses 2σ channels to capture extreme oversold/overbought
  2. Loose Stoploss: Gives strategy ample drawdown space
  3. Long-period Filtering: 72 periods filters short-term noise

For quantitative traders, this is a strategy that requires cautious use:

  • ROI parameter over-optimization risk is relatively high
  • 32.5% stoploss is too loose, recommend adjustment
  • Suitable for volatile range-bound markets