BB_RPB_TSL_c7c477d_20211030 Strategy In-Depth Analysis
Strategy Number: #451 (451st out of 465 strategies) Strategy Type: Bollinger Bands Breakout + Pullback Buy + Custom Trailing Stop Loss Timeframe: 5 minutes (5m) + 1-hour information layer (1h)
I. Strategy Overview
BB_RPB_TSL_c7c477d_20211030 is a strategy combining Bollinger Bands breakout with pullback buying, equipped with a multi-layer dynamic trailing stop loss mechanism. The strategy integrates the RPB (Real Pull Back) concept and BigZ04_TSL's custom stop loss logic, achieving refined configuration through Hyperopt parameter optimization.
Core Features
| Feature | Description |
|---|---|
| Buy Conditions | 7 independent buy signal groups, can trigger independently |
| Sell Conditions | 2 groups of base sell signals + BTC market protection mechanism |
| Protection Mechanism | BTC crash protection (5-minute + 1-day dual check) |
| Timeframe | Main 5m + Information 1h (Ichimoku Cloud) |
| Dependencies | qtpylib, talib, pandas_ta, technical.indicators |
| Special Mechanism | Custom trailing stop loss (tiered dynamic profit-taking) |
II. Strategy Configuration Analysis
2.1 Base Risk Parameters
# ROI Exit Table
minimal_roi = {
"0": 0.10, # 10% profit target
}
# Base stop loss setting
stoploss = -0.10 # 10% hard stop loss (disabled, taken over by custom stop loss)
# Custom stop loss enabled
use_custom_stoploss = True
use_sell_signal = True
Design Philosophy:
- ROI set at 10%, but primarily relies on custom trailing stop loss for dynamic exit
- Base stop loss set at -10% as bottom-line protection, actually executed by custom_stoploss function
- Achieves "higher profit, tighter stop loss" dynamic risk control through tiered trailing stop loss
2.2 Custom Trailing Stop Loss Mechanism
# Trailing stop loss parameters (from Hyperopt optimization)
pHSL = -0.178 # Hard stop loss profit baseline
pPF_1 = 0.01 # First profit threshold (1%)
pSL_1 = 0.009 # First stop loss value (0.9%)
pPF_2 = 0.048 # Second profit threshold (4.8%)
pSL_2 = 0.043 # Second stop loss value (4.3%)
Stop Loss Logic:
- Profit < 1%: Use hard stop loss pHSL (-17.8%)
- Profit 1% ~ 4.8%: Stop loss value linearly interpolated between SL_1 and SL_2
- Profit > 4.8%: Stop loss value increases linearly with profit (higher profit, tighter protection)
III. Buy Conditions Detailed Explanation
3.1 BTC Protection Mechanism (Dual Check)
All buy signals must pass BTC safety check before execution:
| Protection Type | Parameter Description | Default Value |
|---|---|---|
| 5-minute crash protection | buy_btc_safe: BTC 5-minute drop threshold | -289 (BTC cannot crash more than threshold in 5 minutes) |
| 1-day crash protection | buy_btc_safe_1d: BTC 1-day drop threshold | -0.05 (BTC 1-day drop not exceeding 5%) |
| Crash threshold calculation | buy_threshold: BTC change threshold | 0.003 |
Logic:
is_btc_safe = (
(dataframe['btc_diff'] > self.buy_btc_safe.value) # BTC 5-minute no crash
& (dataframe['btc_5m'] - dataframe['btc_1d'] > dataframe['btc_1d'] * self.buy_btc_safe_1d.value) # BTC 1-day no crash
& (dataframe['volume'] > 0) # Has volume
)
3.2 7 Buy Conditions Detailed Explanation
Condition #1: BB Joint Signal (is_BB_checked)
Combined Logic: is_dip (oversold check) + is_break (breakout check)
# is_dip: Oversold state detection
- rmi_length < 49 (RMI Relative Momentum Index oversold)
- cci_length <= -116 (CCI Commodity Channel Index oversold)
- srsi_fk < 32 (Stochastic RSI fast line oversold)
# is_break: Bollinger Bands breakout detection
- bb_delta > 0.025 (Distance between Bollinger Bands lower band and lower band 3)
- bb_width > 0.095 (Bollinger Bands width sufficiently wide)
- closedelta > close * 0.012 (Price change sufficient)
- close < bb_lowerband3 * 0.999 (Price touches Bollinger Bands lower band 3)
Trigger Requirement: Must satisfy both dip and break conditions simultaneously
Condition #2: Local Uptrend (is_local_uptrend)
# From NFI Next Gen strategy
- ema_26 > ema_12 (EMA 26 above EMA 12)
- ema_26 - ema_12 > open * 0.022 (Moving average gap sufficient)
- ema_26.shift - ema_12.shift > open / 100 (Previous moving average gap)
- close < bb_lowerband2 * 0.999 (Price touches Bollinger Bands lower band 2)
- closedelta > close * 0.012 (Price change sufficient)
Condition #3: EWO Signal (is_ewo)
# From SMA offset strategy
- rsi_fast < 45 (Fast RSI oversold)
- close < ema_8 * 0.942 (Price below EMA 8)
- EWO > -5.585 (EWO indicator positive)
- close < ema_16 * 1.084 (Price below EMA 16)
- rsi < 35 (RSI oversold)
Condition #4: EWO High Value Signal (is_ewo_2)
# EWO high value version
- rsi_fast < 45
- close < ema_8 * 0.970
- EWO > 2.055 (EWO higher value)
- close < ema_16 * 1.087
- rsi < 35
Condition #5: COFI + Ichimoku Signal (is_cofi_checked)
# COFI signal
- open < ema_8 * 0.98 (Open price below EMA 8)
- fastk crosses above fastd (Stochastic indicator golden cross)
- fastk < 30 & fastd < 30 (Both indicators oversold)
- adx > 20 (ADX trend strength)
- EWO > 2.055
# Ichimoku Cloud confirmation
- tenkan_sen > kijun_sen (Conversion line > Base line)
- close > cloud_top (Price above cloud top)
- leading_senkou_span_a > leading_senkou_span_b (Cloud bullish)
- chikou_span_greater (Chikou span above cloud)
Condition #6: NFI 32 Signal (is_nfi_32)
# NFI fast mode
- rsi_slow < rsi_slow.shift (Slow RSI declining)
- rsi_fast < 46 (Fast RSI oversold)
- rsi > 19 (RSI not extremely oversold)
- close < sma_15 * 0.942 (Price below SMA 15)
- cti < -0.86 (CTI indicator oversold)
Condition #7: NFI 33 Signal (is_nfi_33)
# NFI precision mode
- close < ema_13 * 0.978
- EWO > 8 (EWO high positive)
- cti < -0.88
- rsi < 32
- r_14 < -98.0 (Williams %R extremely oversold)
- volume < volume_mean_4 * 2.5 (Volume not high)
3.3 Buy Conditions Classification Summary
| Condition Group | Condition Numbers | Core Logic | Hyperopt Status |
|---|---|---|---|
| Oversold Rebound | #1 BB_checked | RMI/CCI/SRSI oversold + BB breakout | Partially enabled |
| Trend Pullback | #2 local_uptrend | EMA moving average trend + BB pullback | Partially enabled |
| EWO Series | #3 ewo, #4 ewo_2 | Elliott Wave Oscillator oversold | Disabled |
| Ichimoku Confirmation | #5 cofi_checked | COFI signal + Ichimoku Cloud | Enabled |
| NFI Series | #6 nfi_32, #7 nfi_33 | NFI oversold patterns | Disabled |
IV. Sell Logic Detailed Explanation
4.1 Base Sell Signals (2 Groups)
# Sell Signal 1: BTC crash exit
- btc_diff < -389 (BTC 5-minute crash exceeds threshold)
# Sell Signal 2: Technical indicator exit
- close < ema_200 * 0.988 (Price below EMA 200)
- cmf < -0.046 (CMF money flow negative)
- (ema_200 - close) / close < 0.022 (Deviation from EMA 200)
- rsi > rsi.shift (RSI rising)
4.2 Custom Trailing Stop Loss Exit
Dynamic stop loss exit through custom_stoploss function, automatically adjusting stop loss position based on current profit:
| Profit Range | Stop Loss Strategy | Description |
|---|---|---|
| < 1% | Hard stop loss -17.8% | Tolerant stop loss, allows volatility |
| 1% ~ 4.8% | Linear interpolation stop loss | Stop loss gradually tightens from 0.9% to 4.3% |
| > 4.8% | Profit lock stop loss | Stop loss increases with profit, protecting gains |
V. Technical Indicator System
5.1 Core Indicators (5-minute timeframe)
| Indicator Category | Specific Indicators | Usage |
|---|---|---|
| Bollinger Bands | BB(20,2), BB(20,3) | Breakout and pullback detection |
| Momentum Indicators | RMI, CCI, SRSI | Oversold state judgment |
| Moving Average System | EMA 8/12/13/16/26/200 | Trend judgment |
| Oscillator Indicators | RSI(4/14/20), Williams %R(14) | Overbought/oversold judgment |
| Volume Indicators | CMF, volume_mean_4 | Capital flow judgment |
| EWO | EWO(50,200) | Elliott Wave Oscillator |
| Trend Strength | ADX, Cofi(fastk/fastd) | Trend strength judgment |
5.2 Information Timeframe Indicators (1-hour)
Strategy uses 1-hour as information layer, providing Ichimoku Cloud judgment:
- Ichimoku Cloud: Conversion line, base line, cloud upper/lower boundaries
- Cloud trend judgment: chikou_span_greater (Chikou span above cloud)
- Cloud type judgment: leading_senkou_span_a > leading_senkou_span_b (bullish cloud)
VI. Risk Management Features
6.1 BTC Market Protection
Strategy has built-in BTC/USDT dual crash protection:
| Protection Layer | Detection Period | Trigger Condition |
|---|---|---|
| 5-minute protection | 5m | BTC 5-minute drop exceeds threshold (default -289) |
| 1-day protection | 1d | BTC 1-day drop exceeds threshold (default -5%) |
Logic: When BTC market crashes, pause all buy operations to avoid building positions in downtrend.
6.2 Custom Trailing Stop Loss
Dynamic stop loss mechanism achieves profit protection:
def custom_stoploss(...):
if (current_profit > PF_2): # Profit > 4.8%
sl_profit = SL_2 + (current_profit - PF_2) # Stop loss increases with profit
elif (current_profit > PF_1): # Profit 1% ~ 4.8%
sl_profit = SL_1 + ((current_profit - PF_1) * (SL_2 - SL_1) / (PF_2 - PF_1)) # Linear interpolation
else: # Profit < 1%
sl_profit = HSL # Hard stop loss
6.3 Hyperopt Parameter Optimization
Strategy provides numerous Hyperopt-optimizable parameters:
| Parameter Group | Optimization Status | Parameter Count |
|---|---|---|
| dip oversold | Disabled | 5 (rmi, cci, srsi_fk, cci_length, rmi_length) |
| break breakout | Disabled | 2 (bb_width, bb_delta) |
| local_uptrend | Disabled | 3 (ema_diff, bb_factor, closedelta) |
| ewo | Disabled | 5 |
| cofi | Enabled | 5 (ema_cofi, fastk, fastd, adx, ewo_high) |
| trailing | Enabled | 5 (pHSL, pPF_1, pSL_1, pPF_2, pSL_2) |
VII. Strategy Advantages and Limitations
✅ Advantages
- Multi-layer buy signals: 7 independent buy conditions, increasing entry opportunity coverage
- BTC market protection: Dual crash protection, avoiding building positions in adverse market conditions
- Dynamic trailing stop loss: Tiered profit-taking mechanism, tighter protection with higher profit
- Ichimoku Cloud confirmation: 1-hour information layer provides trend direction confirmation
- Hyperopt optimization friendly: Numerous parameters can be optimized, easy to adapt to different markets
⚠️ Limitations
- Complex parameters: Over 30 Hyperopt parameters, high optimization difficulty
- BTC dependency: Requires BTC/USDT data, multi-coin strategies need BTC pair configuration
- Computationally intensive: Large number of indicator calculations, certain hardware requirements
- No sell signals: Primarily relies on trailing stop loss for exit, fewer active sell signals
VIII. Applicable Scenario Recommendations
| Market Environment | Recommended Configuration | Description |
|---|---|---|
| Sideways market | Enable dip + break conditions | Oversold rebound strategy effective |
| Trend market | Enable local_uptrend + cofi | Trend pullback entry |
| BTC stable | All conditions enabled | Strategy performs best when market is stable |
| BTC crash | Auto disable buys | BTC protection mechanism automatically activates |
IX. Applicable Market Environment Detailed Explanation
BB_RPB_TSL series is an important member of the Bollinger Bands strategy family. Based on its code architecture and community long-term live trading verification experience, it is most suitable for sideways to bullish markets, and performs poorly during BTC crashes or extreme declines.
9.1 Strategy Core Logic
- Oversold rebound: Detect oversold state through RMI/CCI/SRSI, wait for Bollinger Bands breakout confirmation
- Trend pullback: Wait for price to pull back to Bollinger Bands lower rail in uptrend
- Market protection: Automatically disable buys when BTC crashes, avoid counter-trend building
- Dynamic stop loss: Tighter stop loss with higher profit, protecting gains while allowing volatility space
9.2 Performance in Different Market Environments
| Market Type | Performance Rating | Reason Analysis |
|---|---|---|
| 📈 Slow bull rise | ⭐⭐⭐⭐⭐ | Oversold rebound and trend pullback signals can both trigger effectively |
| 🔄 Sideways consolidation | ⭐⭐⭐⭐☆ | Oversold rebound strategy performs well, but stop loss may trigger frequently |
| 📉 Continuous decline | ⭐⭐☆☆☆ | BTC protection mechanism frequently activates, few buy opportunities |
| ⚡️ BTC crash | ⭐☆☆☆☆ | Buys automatically disabled, strategy enters sleep state |
9.3 Key Configuration Recommendations
| Configuration Item | Recommended Value | Description |
|---|---|---|
| BTC info pair | Must configure | BTC/USDT 5m and 1d data is the foundation of protection mechanism |
| trailing parameters | Enable optimization | Trailing stop loss parameters have significant impact on final returns |
| Hyperopt time | > 500 epochs | Numerous parameters, need sufficient optimization time |
X. Important Reminder: The Cost of Complexity
10.1 Learning Cost
Strategy integrates Bollinger Bands, Ichimoku, EWO, NFI and other technical systems, beginners need to understand:
- Meaning of Bollinger Bands breakout and pullback
- Ichimoku Cloud trend judgment method
- EWO (Elliott Wave Oscillator) usage
- Custom trailing stop loss working principle
10.2 Hardware Requirements
| Number of Trading Pairs | Minimum Memory | Recommended Memory |
|---|---|---|
| < 10 pairs | 2 GB | 4 GB |
| 10 ~ 30 pairs | 4 GB | 8 GB |
| > 30 pairs | 8 GB | 16 GB |
10.3 Differences Between Backtesting and Live Trading
BTC protection mechanism in backtesting is based on historical data, BTC real-time data in live trading may produce different protection effects. Recommendations:
- Use Dry-run mode to test BTC protection effect
- Observe whether strategy correctly disables buys during BTC crashes
10.4 Manual Trader Recommendations
Not recommended to execute this strategy manually, reasons:
- BTC protection requires real-time monitoring of BTC/USDT data
- 7 buy condition judgments are complex, manual real-time decision-making is difficult
- Custom trailing stop loss requires dynamic calculation, manual precise execution is difficult
XI. Summary
BB_RPB_TSL_c7c477d_20211030 is a multi-dimensional quantitative strategy integrating Bollinger Bands breakout, oversold rebound, Ichimoku trend confirmation, and BTC market protection. Its core value lies in:
- Entry diversity: 7 buy conditions covering oversold rebound, trend pullback and other scenarios
- Market linkage: BTC protection mechanism achieves intelligent linkage with the market
- Dynamic risk control: Tiered trailing stop loss achieves tighter protection with higher profit
- Trend confirmation: Ichimoku Cloud provides 1-hour level trend direction confirmation
For quantitative traders, this is a mature strategy suitable for sideways to bullish markets, but requires full understanding of BTC protection mechanism and trailing stop loss working principles, and sufficient Hyperopt optimization time investment.