Skip to main content

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

FeatureDescription
Buy Conditions7 independent buy signal groups, can trigger independently
Sell Conditions2 groups of base sell signals + BTC market protection mechanism
Protection MechanismBTC crash protection (5-minute + 1-day dual check)
TimeframeMain 5m + Information 1h (Ichimoku Cloud)
Dependenciesqtpylib, talib, pandas_ta, technical.indicators
Special MechanismCustom 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 TypeParameter DescriptionDefault Value
5-minute crash protectionbuy_btc_safe: BTC 5-minute drop threshold-289 (BTC cannot crash more than threshold in 5 minutes)
1-day crash protectionbuy_btc_safe_1d: BTC 1-day drop threshold-0.05 (BTC 1-day drop not exceeding 5%)
Crash threshold calculationbuy_threshold: BTC change threshold0.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 GroupCondition NumbersCore LogicHyperopt Status
Oversold Rebound#1 BB_checkedRMI/CCI/SRSI oversold + BB breakoutPartially enabled
Trend Pullback#2 local_uptrendEMA moving average trend + BB pullbackPartially enabled
EWO Series#3 ewo, #4 ewo_2Elliott Wave Oscillator oversoldDisabled
Ichimoku Confirmation#5 cofi_checkedCOFI signal + Ichimoku CloudEnabled
NFI Series#6 nfi_32, #7 nfi_33NFI oversold patternsDisabled

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 RangeStop Loss StrategyDescription
< 1%Hard stop loss -17.8%Tolerant stop loss, allows volatility
1% ~ 4.8%Linear interpolation stop lossStop loss gradually tightens from 0.9% to 4.3%
> 4.8%Profit lock stop lossStop loss increases with profit, protecting gains

V. Technical Indicator System

5.1 Core Indicators (5-minute timeframe)

Indicator CategorySpecific IndicatorsUsage
Bollinger BandsBB(20,2), BB(20,3)Breakout and pullback detection
Momentum IndicatorsRMI, CCI, SRSIOversold state judgment
Moving Average SystemEMA 8/12/13/16/26/200Trend judgment
Oscillator IndicatorsRSI(4/14/20), Williams %R(14)Overbought/oversold judgment
Volume IndicatorsCMF, volume_mean_4Capital flow judgment
EWOEWO(50,200)Elliott Wave Oscillator
Trend StrengthADX, 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 LayerDetection PeriodTrigger Condition
5-minute protection5mBTC 5-minute drop exceeds threshold (default -289)
1-day protection1dBTC 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 GroupOptimization StatusParameter Count
dip oversoldDisabled5 (rmi, cci, srsi_fk, cci_length, rmi_length)
break breakoutDisabled2 (bb_width, bb_delta)
local_uptrendDisabled3 (ema_diff, bb_factor, closedelta)
ewoDisabled5
cofiEnabled5 (ema_cofi, fastk, fastd, adx, ewo_high)
trailingEnabled5 (pHSL, pPF_1, pSL_1, pPF_2, pSL_2)

VII. Strategy Advantages and Limitations

✅ Advantages

  1. Multi-layer buy signals: 7 independent buy conditions, increasing entry opportunity coverage
  2. BTC market protection: Dual crash protection, avoiding building positions in adverse market conditions
  3. Dynamic trailing stop loss: Tiered profit-taking mechanism, tighter protection with higher profit
  4. Ichimoku Cloud confirmation: 1-hour information layer provides trend direction confirmation
  5. Hyperopt optimization friendly: Numerous parameters can be optimized, easy to adapt to different markets

⚠️ Limitations

  1. Complex parameters: Over 30 Hyperopt parameters, high optimization difficulty
  2. BTC dependency: Requires BTC/USDT data, multi-coin strategies need BTC pair configuration
  3. Computationally intensive: Large number of indicator calculations, certain hardware requirements
  4. No sell signals: Primarily relies on trailing stop loss for exit, fewer active sell signals

VIII. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Sideways marketEnable dip + break conditionsOversold rebound strategy effective
Trend marketEnable local_uptrend + cofiTrend pullback entry
BTC stableAll conditions enabledStrategy performs best when market is stable
BTC crashAuto disable buysBTC 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 TypePerformance RatingReason 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 ItemRecommended ValueDescription
BTC info pairMust configureBTC/USDT 5m and 1d data is the foundation of protection mechanism
trailing parametersEnable optimizationTrailing stop loss parameters have significant impact on final returns
Hyperopt time> 500 epochsNumerous 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 PairsMinimum MemoryRecommended Memory
< 10 pairs2 GB4 GB
10 ~ 30 pairs4 GB8 GB
> 30 pairs8 GB16 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:

  1. Entry diversity: 7 buy conditions covering oversold rebound, trend pullback and other scenarios
  2. Market linkage: BTC protection mechanism achieves intelligent linkage with the market
  3. Dynamic risk control: Tiered trailing stop loss achieves tighter protection with higher profit
  4. 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.