Skip to main content

BBRSI4cust Strategy In-Depth Analysis

Strategy Number: #428 (428th of 465 strategies)
Strategy Type: Bollinger Bands + DI Dynamic Parameter Strategy
Timeframe: 15 minutes (15m)


I. Strategy Overview

BBRSI4cust is an optimizable strategy based on Bollinger Bands and Directional Indicator (DI). Unlike BBRSI3366's minimalist style, this strategy introduces Hyperopt-optimizable parameters, allowing the determination of optimal Bollinger Band standard deviation and DI thresholds through backtest optimization, providing greater adaptability.

Core Features

FeatureDescription
Buy Condition1 combined signal: DI > threshold + price breaks below Bollinger lower band
Sell ConditionSignal sell + custom exit logic
Protection MechanismTrailing stop + fixed stop loss(-10%) + custom exit
Timeframe15 minutes (medium-term trading)
Dependenciestalib, qtpylib, numpy, pandas
Optimizable Parameters3 (buy_bb, buy_di, sell_bb)

II. Strategy Configuration Analysis

2.1 Basic Risk Parameters

# ROI exit table
minimal_roi = {
"0": 0.003 # Exit immediately if 0.3% profit reached
}

# Stop loss setting
stoploss = -0.1 # 10% stop loss (reasonable)

# Trailing stop
trailing_stop = True
# Following parameters are commented, using default values
# trailing_only_offset_is_reached = False
# trailing_stop_positive = 0.01
# trailing_stop_positive_offset = 0.0

Design Philosophy:

  • ROI set to 0.3%, a very conservative target, indicating the strategy relies more on signal exits
  • Stop loss of -10% is much more reasonable compared to BBRSI3366's -33%
  • Trailing stop is enabled but specific parameters are not configured, using Freqtrade defaults

2.2 Order Type Configuration

order_types = {
'entry': 'limit', # Entry uses limit orders
'exit': 'limit', # Exit uses limit orders
'stoploss': 'market', # Stop loss uses market orders
'stoploss_on_exchange': False
}

order_time_in_force = {
'entry': 'gtc', # Good Till Cancel
'exit': 'gtc'
}

III. Buy Condition Details

3.1 Buy Signal Composition

The strategy's buy condition requires three conditions to be met simultaneously:

def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['plus_di'] > self.buy_di.value) &
(qtpylib.crossed_below(dataframe['low'], dataframe['bb_lowerband'])) &
(dataframe['volume'] > 0)
),
'enter_long'] = 1
return dataframe

Condition #1: Plus Directional Indicator (+DI) Filter

(dataframe['plus_di'] > self.buy_di.value)
  • Description: +DI (Plus Directional Indicator) represents the strength of the uptrend
  • Parameter: buy_di optimizable range is 10-20, default value 20
  • Logic: When +DI is above the threshold, it indicates some upward momentum

Condition #2: Price Breaks Below Bollinger Lower Band

(qtpylib.crossed_below(dataframe['low'], dataframe['bb_lowerband']))
  • Description: Low price crosses below the Bollinger lower band
  • Parameter: Bollinger Band standard deviation buy_bb optimizable range is 1-4, default value 1
  • Logic: When price touches or breaks below the Bollinger lower band, it may be an oversold opportunity

Condition #3: Volume Verification

(dataframe['volume'] > 0)
  • Description: Ensures there is volume
  • Logic: Basic filter to prevent trading without liquidity

3.2 Optimizable Parameter Details

ParameterRangeDefaultDescription
buy_bb1-41Bollinger Band standard deviation multiplier, affects lower band position for entry
buy_di10-2020+DI threshold, higher value means stricter buy condition

Parameter Impact Analysis:

  • buy_bb = 1: Standard Bollinger Bands, narrower lower band, more frequent signals
  • buy_bb = 4: Wider lower band, fewer signals but potentially more reliable
  • buy_di = 10: Loose condition, more buying opportunities
  • buy_di = 20: Strict condition, only buys when there's clear upward momentum

IV. Sell Logic Details

4.1 Signal Sell Condition

def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['high'], dataframe['bb_middleband1'])) &
(dataframe['volume'] > 0)
),
'exit_long'] = 1
return dataframe
ConditionDescription
high crossed above bb_middleband1High price crosses above Bollinger middle band
volume > 0Ensures there is volume

Design Logic: Sell when price crosses above the Bollinger middle band from below, indicating the oversold bounce has completed.

4.2 Custom Exit Logic

The strategy also implements the custom_exit method, providing an additional exit mechanism:

def custom_exit(self, pair: str, trade: 'Trade', current_time: 'datetime', 
current_rate: float, current_profit: float, **kwargs):
dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
current_candle = dataframe.iloc[-1].squeeze()

if (qtpylib.crossed_above(current_rate, current_candle['bb_middleband1'])):
return "bb_profit_sell"

return None

Exit Signal: bb_profit_sell

  • Trigger Condition: Current price crosses above the Bollinger middle band
  • Purpose: Provides a more precise exit point based on real-time price rather than historical data

4.3 Sell Parameters

ParameterRangeDefaultDescription
sell_bb1-41Sell Bollinger Band standard deviation multiplier

V. Technical Indicator System

5.1 Core Indicators

Indicator CategorySpecific IndicatorPurpose
Trend Indicator+DI (Plus Directional Indicator)Buy signal filter
Momentum IndicatorRSI(14)Calculated but not used in signals
Trend IndicatorBollinger Bands(20, stds=buy_bb)Buy signal
Trend IndicatorBollinger Bands(20, stds=sell_bb)Sell signal

5.2 Indicator Calculation Code

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# Plus Directional Indicator
dataframe['plus_di'] = ta.PLUS_DI(dataframe)
dataframe['di_overbought'] = 20 # Reference line

# RSI
dataframe['rsi'] = ta.RSI(dataframe)

# Bollinger Bands for entry
bollinger = qtpylib.bollinger_bands(
qtpylib.typical_price(dataframe), window=20, stds=self.buy_bb.value
)
dataframe['bb_lowerband'] = bollinger['lower']
dataframe['bb_middleband'] = bollinger['mid']
dataframe['bb_upperband'] = bollinger['upper']

# Bollinger Bands for exit
bollinger1 = qtpylib.bollinger_bands(
qtpylib.typical_price(dataframe), window=20, stds=self.sell_bb.value
)
dataframe['bb_lowerband1'] = bollinger1['lower']
dataframe['bb_middleband1'] = bollinger1['mid']
dataframe['bb_upperband1'] = bollinger1['upper']

return dataframe

5.3 Dual Bollinger Bands Design

The strategy uses two sets of Bollinger Bands:

  • Entry Bollinger Bands: Uses buy_bb parameter for buy signals
  • Exit Bollinger Bands: Uses sell_bb parameter for sell signals

Design Advantage: Entry and exit can use different standard deviation multipliers, increasing strategy flexibility.


VI. Risk Management Features

6.1 Reasonable Stop Loss Setting

stoploss = -0.1  # 10% stop loss

Compared to BBRSI3366's -33%, this stop loss setting is much more reasonable:

  • Single trade maximum loss controlled at 10%
  • Gives the strategy enough room for volatility
  • Not too loose to cause substantial losses

6.2 Conservative ROI Target

minimal_roi = {"0": 0.003}  # 0.3%
  • ROI target set at 0.3%, very conservative
  • Indicates the strategy relies mainly on signal exits rather than ROI take profit
  • Avoids premature profit-taking that misses subsequent moves

6.3 Multi-layer Exit Mechanism

Exit MechanismTrigger ConditionPriority
ROI Take ProfitProfit reaches 0.3%High
Custom ExitPrice crosses above Bollinger middle bandMedium
Signal SellHigh price crosses above Bollinger middle bandMedium
Stop LossLoss reaches -10%Fallback

VII. Strategy Advantages and Limitations

✅ Advantages

  1. Optimizable Parameters: 3 Hyperopt parameters, can be adjusted for different markets
  2. Dual Bollinger Bands: Different parameters for entry and exit, more flexible
  3. Trend Filter: +DI condition avoids buying in pure downtrends
  4. Reasonable Stop Loss: -10% stop loss setting is relatively prudent
  5. Custom Exit: Provides more precise exit points

⚠️ Limitations

  1. RSI Not Used: RSI is calculated but not used in signals
  2. ROI Too Low: 0.3% target may lead to frequent trading
  3. Parameter Optimization Risk: Optimizable parameters may increase overfitting risk
  4. Single Buy Signal: Although there's a trend filter, the buy condition is still relatively simple

VIII. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Ranging Marketbuy_bb=2, buy_di=15Use wider Bollinger Bands, reduce false signals
Uptrendbuy_bb=1, buy_di=20Standard Bollinger Bands, strict DI filter
DowntrendUse with caution+DI may stay below threshold for extended periods
High Volatilitybuy_bb=3-4Wider Bollinger Bands, avoid frequent triggers

IX. Applicable Market Environment Details

BBRSI4cust is a parameter-adaptive short-term strategy. Its core feature is introducing optimizable parameters, allowing it to adjust trading parameters based on market conditions.

9.1 Strategy Core Logic

  • Trend Confirmation: +DI > threshold indicates some uptrend strength
  • Oversold Buy: Buy when price breaks below Bollinger lower band
  • Mean Reversion: Sell when price reverts to Bollinger middle band

9.2 Performance in Different Market Environments

Market TypePerformance RatingReason Analysis
📈 Slow Bull Range⭐⭐⭐⭐☆+DI filter effective, Bollinger reversal signals accurate
🔄 Sideways Range⭐⭐⭐⭐⭐Best scenario, Bollinger upper/lower band trading works well
📉 Downtrend⭐⭐☆☆☆+DI may stay below threshold for extended periods, fewer signals
⚡️ High Volatility⭐⭐⭐☆☆Can adapt by adjusting buy_bb parameter

9.3 Key Configuration Recommendations

Configuration ItemRecommended ValueDescription
buy_bb1-2Adjust based on market volatility
buy_di15-20Lower value for stronger trending markets
sell_bb1-2Use in coordination with buy_bb
minimal_roi0.01-0.02Can appropriately raise target profit

X. Important Reminder: The Cost of Complexity

10.1 Learning Cost

This strategy introduces Hyperopt parameter optimization concepts, requiring understanding of:

  • Freqtrade's parameter optimization mechanism
  • How to use hyperopt command for parameter optimization
  • How to avoid overfitting

10.2 Hardware Requirements

Number of Trading PairsMinimum MemoryRecommended Memory
1-10 pairs2GB4GB
10-50 pairs4GB8GB
50+ pairs8GB16GB

10.3 Backtest vs Live Trading Differences

Since the strategy uses optimizable parameters, special attention is needed:

  • Overfitting Risk: Optimized parameters may only work for historical data
  • Parameter Stability: Need to use rolling window validation for parameter stability
  • Market Changes: Market structure changes may cause parameters to become invalid

10.4 Manual Trading Recommendations

Key points for manually trading this strategy:

  1. Set +DI indicator (usually part of the ADX system)
  2. Set Bollinger Bands (period 20, adjustable standard deviation)
  3. Buy condition: +DI > threshold AND price breaks below Bollinger lower band
  4. Sell condition: Price returns to Bollinger middle band

XI. Summary

BBRSI4cust is an optimizable Bollinger Band reversal strategy. Its core value lies in:

  1. Parameter Flexibility: Can adjust parameters based on market through Hyperopt
  2. Trend Filter: +DI condition provides trend confirmation
  3. Dual Bollinger Band Design: Different parameters for entry and exit
  4. Reasonable Risk Control: -10% stop loss setting is prudent

For quantitative traders, this strategy is suitable as a base template for Bollinger Band strategies. Parameters can be optimized and strategies improved based on actual market conditions.