Skip to main content

BB_RPB_TSL_RNG_2 Strategy In-Depth Analysis

Strategy Number: #443 (443rd of 465 strategies)
Strategy Type: Bollinger Bands Breakout + Pullback Buy + Custom Trailing Stop
Timeframe: 5 minutes (5m) + 1 hour information layer


I. Strategy Overview

BB_RPB_TSL_RNG_2 is a multi-condition quantitative strategy based on Bollinger Bands breakout and pullback buying. The strategy name components: BB represents Bollinger Bands, RPB represents Real Pull Back, and TSL represents Trailing Stop Loss. This strategy integrates multiple technical indicators and buy signals, combined with a custom trailing stop mechanism, aiming to capture pullback opportunities within trends.

Core Features

FeatureDescription
Buy Conditions7 independent buy signals, can be enabled/disabled individually
Sell Conditions2 groups of sell signal combinations + custom trailing stop
Protection MechanismTiered trailing stop system (3 levels)
Timeframe5m main framework + 1h information framework
Dependenciesqtpylib, numpy, talib, pandas_ta, technical
BTC ProtectionReserved BTC short-term crash protection (commented out in code)

II. Strategy Configuration Analysis

2.1 Basic Risk Parameters

# ROI Exit Table - Fixed 10% Take Profit
minimal_roi = {
"0": 0.10,
}

# Stop Loss Setting - Fixed 10% (overridden by custom stop)
stoploss = -0.10

# Enable Custom Trailing Stop
use_custom_stoploss = True
use_sell_signal = True

Design Rationale:

  • ROI set at 10%, actual exits primarily rely on trailing stop mechanism
  • Fixed stop loss at -10% serves as final defense line; custom trailing stop gradually moves up after profit
  • Sell signals enabled, providing active exit capability

2.2 Tiered Trailing Stop Parameters

# Hard Stop Loss (when at loss)
pHSL = -0.178 # -17.8%

# Level 1: Triggered at 1.9% profit
pPF_1 = 0.019 # Trigger threshold
pSL_1 = 0.019 # Stop loss protection

# Level 2: Triggered at 6.5% profit
pPF_2 = 0.065 # Trigger threshold
pSL_2 = 0.062 # Stop loss protection

Trailing Stop Logic:

Profit RangeStop Loss ProtectionDescription
< 1.9%-17.8%Use hard stop loss
1.9% ~ 6.5%Linear interpolation1.9% ~ 6.2%
> 6.5%Dynamic upward movementFollows profit growth

III. Buy Conditions Detailed Analysis

3.1 Switchable Parameters

The strategy provides two buy condition switches:

buy_is_dip_enabled = True   # Enable pullback buying
buy_is_break_enabled = True # Enable breakout buying

3.2 Seven Buy Conditions Detailed

Condition #1: BB Checked (Bollinger Bands Pullback Breakout Combination)

is_BB_checked = is_dip & is_break

# is_dip sub-conditions
- RMI(17) < 49 # Relative Momentum Index below threshold
- CCI(25) <= -116 # Commodity Channel Index oversold
- SRSI_FK < 32 # Stochastic RSI fast line below threshold

# is_break sub-conditions
- bb_delta > 0.025 # Bollinger Bands lower band 2 and 3 gap > 2.5%
- bb_width > 0.095 # Bollinger Bands width > 9.5%
- close_delta > close * 0.012 # Price movement sufficient
- close < bb_lowerband3 * 0.999 # Price near or below 3 standard deviation lower band

Trigger Scenario: Price breaks below Bollinger Bands lower band while momentum indicators show oversold conditions.


Condition #2: Local Uptrend

is_local_uptrend = (
(ema_26 > ema_12) & # Long-term EMA above short-term EMA
(ema_26 - ema_12 > open * 0.022) & # EMA gap sufficiently large
(ema_26.shift() - ema_12.shift() > open / 100) & # Previous candle also satisfies
(close < bb_lowerband2 * 0.999) & # Price below Bollinger Bands lower band
(closedelta > close * 0.012) # Price movement sufficient
)

Trigger Scenario: Pullback within an uptrend, price touches Bollinger Bands lower band.


Condition #3: EWO (Elliott Wave Oscillator)

is_ewo = (
(rsi_fast < 45) & # Fast RSI below threshold
(close < ema_8 * 0.942) & # Price below EMA(8)
(EWO > -5.585) & # Elliott Wave Oscillator
(close < ema_16 * 1.084) & # Price upper constraint
(rsi < 35) # RSI oversold
)

Trigger Scenario: Pullback buy opportunity based on Elliott Wave theory.


Condition #4: EWO 2 (EWO Variant)

is_ewo_2 = (
(rsi_fast < 45) &
(close < ema_8 * 0.970) & # More relaxed lower bound
(EWO > 4.179) & # Positive EWO value
(close < ema_16 * 1.087) &
(rsi < 35)
)

Trigger Scenario: Pullback opportunity when EWO shows upward momentum.


Condition #5: Cofi (Stochastic Fast + ADX Combination)

is_cofi = (
(open < ema_8 * 0.98) & # Open price below EMA
(fastk crossed_above fastd) & # Stochastic golden cross
(fastk < 22) & # Fast line below threshold
(fastd < 20) & # Slow line below threshold
(adx > 20) & # ADX shows trend strength
(EWO > 4.179)
)

Trigger Scenario: Stochastic golden cross confirmation in oversold zone.


Condition #6: NFI 32 (Fast Indicator Combination)

is_nfi_32 = (
(rsi_slow < rsi_slow.shift(1)) & # Slow RSI declining
(rsi_fast < 46) & # Fast RSI threshold
(rsi > 19) & # RSI lower bound
(close < sma_15 * 0.942) & # Price below SMA
(cti < -0.86) # Relative trend indicator extremely low
)

Trigger Scenario: Deep pullback but not complete crash.


Condition #7: NFI 33 (Extreme Oversold)

is_nfi_33 = (
(close < ema_13 * 0.978) & # Price below EMA
(EWO > 8) & # Strong momentum
(cti < -0.88) & # Extreme trend indicator
(rsi < 32) & # RSI oversold
(r_14 < -98.0) & # Williams %R extreme value
(volume < volume_mean_4 * 2.5) # Volume constraint
)

Trigger Scenario: Rebound opportunity in extreme oversold conditions.


3.3 Buy Conditions Classification Summary

Condition GroupCondition NumberCore LogicBuy Tag
Bollinger Bands Combination#1Oversold + Breakout combinationbb
Trend Pullback#2Uptrend pullbacklocal uptrend
Elliott Wave#3EWO pullback buyewo
Elliott Wave Variant#4EWO momentum upwardewo2
Stochastic#5Golden cross + trend confirmationcofi
NFI Fast#6Deep pullbacknfi 32
NFI Extreme#7Extreme oversold reboundnfi 33

IV. Sell Logic Detailed Analysis

4.1 Sell Signal Combinations

The strategy uses two groups of sell conditions (OR relationship):

Sell Condition Group 1:

(close > sma_9) &  # Price above short-term SMA
(close > ma_sell * 1.02) & # Price above sell MA * offset
(rsi > 50) & # RSI enters bullish zone
(volume > 0) & # Has volume
(rsi_fast > rsi_slow) # Fast RSI above slow RSI

Sell Condition Group 2:

(sma_9 > sma_9.shift(1) * 1.005) &  # SMA rising slope
(close < hma_50) & # Price below HMA
(close > ma_sell * 1.051) & # Price above sell MA
(volume > 0) &
(rsi_fast > rsi_slow)

4.2 Sell Parameters

ParameterDefault ValueDescription
base_nb_candles_sell23Sell MA period
high_offset1.051Sell price offset (high position)
high_offset_21.02Sell price offset (low position)

V. Technical Indicator System

5.1 Core Indicators

Indicator CategorySpecific IndicatorsUsage
Bollinger BandsBB(20,2), BB(20,3)Price channel, breakout signals
EMAEMA(8,12,13,16,26,100)Trend judgment, support/resistance
SMASMA(9,15,30)Price MA, sell signals
RSIRSI(4,14,20)Overbought/oversold, momentum
CCICCI(26,170)Commodity Channel Index
RMIRMI(variable period)Relative Momentum Index
SRSIStochRSI(15,20,2,2)Stochastic RSI
EWOElliott Wave(50,200)Elliott Wave Oscillator
ADXADX(default)Trend strength
Williams %RWR(14)Overbought/oversold
CTICTI(20)Relative Trend Index
HMAHMA(50)Hull Moving Average

5.2 BTC Protection Mechanism (Reserved)

Code reserves BTC crash protection logic:

# BTC 5-minute crash protection
btc_diff > buy_btc_safe # BTC 5-minute drop not exceeding threshold

# BTC 1-day decline protection
btc_5m - btc_1d > btc_1d * buy_btc_safe_1d # BTC daily decline limit

This protection is currently commented out in code and can be enabled for live trading.


VI. Risk Management Features

6.1 Custom Trailing Stop System

The strategy employs a 3-tier tiered trailing stop:

def custom_stoploss(self, pair, trade, current_time, current_rate, current_profit, **kwargs):
HSL = -0.178 # Hard stop loss

if current_profit > 0.065:
# Profit > 6.5%: stop loss follows profit upward
sl_profit = 0.062 + (current_profit - 0.065)
elif current_profit > 0.019:
# Profit 1.9%~6.5%: linear interpolation
sl_profit = 0.019 + ((current_profit - 0.019) * (0.062 - 0.019) / (0.065 - 0.019))
else:
# Profit < 1.9%: use hard stop loss
sl_profit = HSL

return stoploss_from_open(sl_profit, current_profit)

6.2 Multi-Layer Buy Confirmation

Strategy buy condition design:

  • Each buy signal has multi-indicator combination verification
  • BB_checked condition requires dip + break to be satisfied simultaneously
  • Volume filtering avoids low liquidity traps

6.3 Hyperopt Optimizable Parameters

The strategy provides numerous optimizable parameters:

Parameter CategoryParameter CountExample
Pullback Buy5buy_rmi, buy_cci, buy_srsi_fk
Bollinger Bands Breakout2buy_bb_width, buy_bb_delta
EWO5buy_ewo, buy_ema_low, buy_ema_high
Cofi4buy_fastk, buy_fastd, buy_adx

VII. Strategy Advantages and Limitations

✅ Advantages

  1. Multi-Signal Confirmation: 7 buy conditions cover various market scenarios, reducing false signal risk
  2. Trailing Stop: Tiered stop loss mechanism effectively locks in profits, letting profits run
  3. Rich Indicators: Integration of Bollinger Bands, RSI, EWO and other indicators, reliable signals
  4. High Configurability: Multiple parameters can be optimized via Hyperopt
  5. Clear Code Structure: Buy conditions clearly categorized, easy to understand and debug

⚠️ Limitations

  1. Numerous Parameters: High optimization difficulty, prone to overfitting
  2. High Computational Complexity: Large indicator calculation load, higher hardware requirements
  3. BTC Protection Not Enabled: Requires manual activation of BTC crash protection
  4. 5-Minute Level: High-frequency trading, significant fee impact
  5. Lack of Stop Loss Flexibility: Hard stop fixed at -17.8%, may not suit all markets

VIII. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Oscillating UpwardDefault configurationBest environment for trend pullback strategy
Clear TrendEnable NFI conditionsCapture trend pullback opportunities
High VolatilityTighten stop lossAdjust pHSL and stop loss parameters
Gradual DeclineUse with cautionMay trigger frequent stop losses

IX. Applicable Market Environment Detailed Analysis

BB_RPB_TSL_RNG_2 is a trend pullback capture strategy. Based on its code architecture and community long-term live trading validation experience, it is best suited for oscillating rising markets, while performing poorly in one-sided declines or extreme volatility.

9.1 Strategy Core Logic

  • Bollinger Bands Breakout: Price rebounds after touching lower band
  • Multi-Indicator Confirmation: RSI, CCI, EWO and other indicators simultaneously confirm oversold conditions
  • Trailing Stop: Stop loss moves up after profit, locking in gains

9.2 Performance in Different Market Environments

Market TypePerformance RatingReason Analysis
📈 Oscillating Rise⭐⭐⭐⭐⭐Strategy design target scenario, pullback buying works well
🔄 Sideways Oscillation⭐⭐⭐☆☆May enter/exit frequently, high fee consumption
📉 One-Sided Decline⭐⭐☆☆☆Pullback buying容易 catch falling knife
⚡️ Extreme Volatility⭐☆☆☆☆Many false breakouts, frequent stop loss triggers

9.3 Key Configuration Recommendations

Configuration ItemRecommended ValueDescription
Timeframe5mStrategy design timeframe
Trading PairsMajor coinsGood liquidity, low slippage
FeesBelow 0.1% MakerHigh-frequency strategy sensitive to fees

X. Important Reminder: The Cost of Complexity

10.1 Learning Cost

Strategy code is approximately 400 lines, involving 15+ technical indicators. Beginners need to:

  • Understand principles of Bollinger Bands, RSI, CCI, EWO and other indicators
  • Master trailing stop working mechanism
  • Familiarize with Hyperopt parameter optimization process

10.2 Hardware Requirements

Number of Trading PairsMinimum MemoryRecommended Memory
1-5 pairs4GB8GB
5-20 pairs8GB16GB
20+ pairs16GB32GB

10.3 Differences Between Backtesting and Live Trading

Strategies performing excellently in backtesting may underperform in live trading due to:

  • Slippage: 5-minute level trading significantly affected by slippage
  • Latency: Exchange API latency may cause execution price deviation
  • Liquidity: May not execute at expected prices during extreme conditions

10.4 Manual Trader Recommendations

Not recommended for manual execution:

  • Complex indicator calculations, difficult to judge in real-time
  • 7 buy condition combinations difficult to confirm simultaneously
  • Trailing stop requires programmatic execution

XI. Summary

BB_RPB_TSL_RNG_2 is a well-designed trend pullback capture strategy. Its core value lies in:

  1. Multi-Signal Fusion: 7 buy conditions cover different pullback scenarios, improving signal quality
  2. Dynamic Stop Loss: Tiered trailing stop effectively protects profits, reducing drawdown
  3. Rich Indicators: Bollinger Bands, EWO, RSI and other multi-dimensional confirmation, reducing false signals
  4. Optimization Space: Numerous parameters can be optimized via Hyperopt for different markets

For quantitative traders, it is recommended to first test thoroughly in a simulated environment, understand the working principles of each condition before deploying to live trading. Enabling the BTC protection mechanism can further reduce systemic risk.