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
| Feature | Description |
|---|---|
| Buy Condition | 1 combined signal: DI > threshold + price breaks below Bollinger lower band |
| Sell Condition | Signal sell + custom exit logic |
| Protection Mechanism | Trailing stop + fixed stop loss(-10%) + custom exit |
| Timeframe | 15 minutes (medium-term trading) |
| Dependencies | talib, qtpylib, numpy, pandas |
| Optimizable Parameters | 3 (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
| Parameter | Range | Default | Description |
|---|---|---|---|
| buy_bb | 1-4 | 1 | Bollinger Band standard deviation multiplier, affects lower band position for entry |
| buy_di | 10-20 | 20 | +DI threshold, higher value means stricter buy condition |
Parameter Impact Analysis:
buy_bb = 1: Standard Bollinger Bands, narrower lower band, more frequent signalsbuy_bb = 4: Wider lower band, fewer signals but potentially more reliablebuy_di = 10: Loose condition, more buying opportunitiesbuy_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
| Condition | Description |
|---|---|
| high crossed above bb_middleband1 | High price crosses above Bollinger middle band |
| volume > 0 | Ensures 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
| Parameter | Range | Default | Description |
|---|---|---|---|
| sell_bb | 1-4 | 1 | Sell Bollinger Band standard deviation multiplier |
V. Technical Indicator System
5.1 Core Indicators
| Indicator Category | Specific Indicator | Purpose |
|---|---|---|
| Trend Indicator | +DI (Plus Directional Indicator) | Buy signal filter |
| Momentum Indicator | RSI(14) | Calculated but not used in signals |
| Trend Indicator | Bollinger Bands(20, stds=buy_bb) | Buy signal |
| Trend Indicator | Bollinger 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_bbparameter for buy signals - Exit Bollinger Bands: Uses
sell_bbparameter 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 Mechanism | Trigger Condition | Priority |
|---|---|---|
| ROI Take Profit | Profit reaches 0.3% | High |
| Custom Exit | Price crosses above Bollinger middle band | Medium |
| Signal Sell | High price crosses above Bollinger middle band | Medium |
| Stop Loss | Loss reaches -10% | Fallback |
VII. Strategy Advantages and Limitations
✅ Advantages
- Optimizable Parameters: 3 Hyperopt parameters, can be adjusted for different markets
- Dual Bollinger Bands: Different parameters for entry and exit, more flexible
- Trend Filter: +DI condition avoids buying in pure downtrends
- Reasonable Stop Loss: -10% stop loss setting is relatively prudent
- Custom Exit: Provides more precise exit points
⚠️ Limitations
- RSI Not Used: RSI is calculated but not used in signals
- ROI Too Low: 0.3% target may lead to frequent trading
- Parameter Optimization Risk: Optimizable parameters may increase overfitting risk
- Single Buy Signal: Although there's a trend filter, the buy condition is still relatively simple
VIII. Applicable Scenario Recommendations
| Market Environment | Recommended Configuration | Description |
|---|---|---|
| Ranging Market | buy_bb=2, buy_di=15 | Use wider Bollinger Bands, reduce false signals |
| Uptrend | buy_bb=1, buy_di=20 | Standard Bollinger Bands, strict DI filter |
| Downtrend | Use with caution | +DI may stay below threshold for extended periods |
| High Volatility | buy_bb=3-4 | Wider 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 Type | Performance Rating | Reason 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 Item | Recommended Value | Description |
|---|---|---|
| buy_bb | 1-2 | Adjust based on market volatility |
| buy_di | 15-20 | Lower value for stronger trending markets |
| sell_bb | 1-2 | Use in coordination with buy_bb |
| minimal_roi | 0.01-0.02 | Can 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 Pairs | Minimum Memory | Recommended Memory |
|---|---|---|
| 1-10 pairs | 2GB | 4GB |
| 10-50 pairs | 4GB | 8GB |
| 50+ pairs | 8GB | 16GB |
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:
- Set +DI indicator (usually part of the ADX system)
- Set Bollinger Bands (period 20, adjustable standard deviation)
- Buy condition: +DI > threshold AND price breaks below Bollinger lower band
- Sell condition: Price returns to Bollinger middle band
XI. Summary
BBRSI4cust is an optimizable Bollinger Band reversal strategy. Its core value lies in:
- Parameter Flexibility: Can adjust parameters based on market through Hyperopt
- Trend Filter: +DI condition provides trend confirmation
- Dual Bollinger Band Design: Different parameters for entry and exit
- 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.