
This strategy is an advanced adaptive trading system that automatically switches between trading modes based on market structure recognition techniques. The strategy utilizes the ADX indicator to determine market conditions, employing an RSI mean-reversion strategy in ranging markets (ADX ≤ 25) and a price breakout strategy in trending markets (ADX > 25). The system first checks a 200-period EMA trend filter to ensure alignment with the major trend direction, while implementing an ATR-based risk management system to set appropriate stop-losses for trades in different market environments. The system is optimized for BTC/USDT on H1/H4 timeframes and improves overall profitability and stability by dynamically adapting to different market conditions.
The core of this strategy is a market structure adaptive mechanism that operates through the following key steps:
Market State Recognition: Uses ADX (Average Directional Index) to determine whether the market is in a ranging or trending state. ADX > 25 indicates a trending market, while ADX ≤ 25 indicates a ranging market.
Trend Direction Filtering: Uses a 200-period EMA as a trend direction filter. Price above EMA is considered bullish, while price below EMA is considered bearish.
Ranging Market Strategy:
Trending Market Strategy:
Risk Management: Each trade risks 10% of account equity, with different stop-loss strategies based on the type of trade.
The strategy uses a time filter to only trade after January 1, 2020, ensuring it operates during more mature phases of the cryptocurrency market.
Market Adaptability: The strategy’s greatest advantage is its ability to automatically switch trading modes based on market conditions, using mean-reversion in ranging markets and breakout techniques in trending markets, allowing it to remain competitive across various market environments.
Trend Alignment: Through the 200 EMA trend filter, the strategy ensures trade direction aligns with the major trend, avoiding the high risks associated with counter-trend trading.
Tailored Risk Control: The strategy employs different risk management methods for different types of trades, using fixed ATR multiplier stops for RSI trades and trailing stops for breakout trades, optimizing the risk/reward characteristics for each trading mode.
Real-time Market Feedback: Through the built-in dashboard, traders can monitor market state, trend bias, and recent trade signals in real-time, facilitating quick decision-making and strategy adjustments.
Parameter Adjustability: The strategy provides multiple customizable parameters, including RSI thresholds, ADX length and threshold, breakout lookback period, etc., allowing traders to optimize based on their risk preferences and market views.
Parameter Sensitivity: Strategy performance is highly dependent on the chosen parameters, such as ADX threshold and RSI levels. Poor parameter selection may lead to frequent market mode switching or incorrect trading signals, increasing unnecessary trading costs and potential losses. The solution is to conduct rigorous backtesting on historical data and select robust parameters suitable for current market conditions.
False Breakout Risk: In trend mode, the strategy is susceptible to false breakouts, especially in highly volatile markets. These false signals may lead to stop-losses being triggered, reducing overall profitability. It is recommended to add additional confirmation indicators or set more conservative breakout conditions to reduce such risks.
Overtrading Risk: Overly sensitive RSI settings in ranging markets may lead to overtrading, increasing commission costs and potentially missing larger price movements. The solution is to adjust RSI thresholds or add additional trade filters to reduce trading frequency.
Fixed Percentage Risk: The strategy uses a fixed 10% of equity as risk for each trade, which may lead to significant account drawdowns in cases of consecutive losses. Implementing a dynamic position sizing mechanism is recommended, adjusting risk exposure based on recent trading performance or market volatility.
Market State Misidentification: The ADX indicator may inaccurately reflect market state under certain market conditions, causing the strategy to select the wrong trading mode. It is advisable to combine other market structure indicators to enhance the accuracy of state determination.
Multi-timeframe Analysis Integration: The strategy can be enhanced by incorporating multi-timeframe analysis for trading decisions, such as using higher timeframe trend direction to filter lower timeframe trading signals, improving overall success rates. Specific implementation could add H4 or daily trend filters to guide H1 trades.
Dynamic Parameter Optimization: Currently, the strategy uses fixed parameters, which could be improved to automatically adjust key parameters based on market volatility or recent price behavior. For example, RSI thresholds could be adjusted according to market volatility, using narrower RSI ranges in low-volatility environments and wider ranges in high-volatility environments.
Advanced Entry Confirmation: Add additional technical indicators as trade confirmations, such as volume analysis, candlestick pattern recognition, or market sentiment indicators. This can reduce false signals and improve entry quality.
More Sophisticated Risk Management: Implement dynamic position management and adaptive stop-loss strategies, adjusting trade size and stop levels based on market volatility, recent profits/losses, or drawdown depth.
Machine Learning Optimization: Use machine learning algorithms to dynamically predict optimal market state thresholds (such as ADX switching points) or identify which trading mode is likely to perform better under specific market conditions, thereby improving strategy adaptability and performance.
The Dual-Regime Adaptive Trading System creates a comprehensive trading system capable of automatically adapting to different market conditions by combining RSI mean-reversion and price breakout strategies. The strategy’s uniqueness lies in its use of the ADX indicator to categorize the market into ranging and trending states and applying the most appropriate trading method for each state. Through EMA trend filtering and ATR-based risk management, the strategy pursues consistent returns while maintaining trading safety. While there are some potential risks, such as parameter sensitivity and market state misidentification, these can be effectively mitigated through the suggested optimization directions, including multi-timeframe analysis, dynamic parameter adjustment, and advanced risk management. For traders seeking to maintain competitiveness across different market environments, this adaptive approach provides a powerful framework, especially when trading volatile assets like Bitcoin.
/*backtest
start: 2024-05-14 00:00:00
end: 2025-05-12 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/
//@version=6
strategy("Improved Hybrid: RSI + Breakout + Dashboard", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === INPUTS ===
stopMult = input.float(1.2, "Stop-Loss ATR Multiplier", minval=0.5, step=0.1)
rsiBuy = input.int(35, "RSI Buy Threshold")
rsiSell = input.int(70, "RSI Sell Threshold")
adxLen = input.int(14, "ADX Length")
adxSmooth = input.int(14, "ADX Smoothing")
adxThreshold = input.float(25, "ADX Threshold")
emaLen = input.int(200, "EMA Trend Filter")
rsiLen = input.int(14, "RSI Length")
exitRSI = input.int(50, "RSI Exit Threshold")
breakoutLen = input.int(20, "Breakout Lookback")
atrLen = input.int(14, "ATR Length")
atrMult = input.float(1.5, "ATR Trailing Multiplier")
// === TIME FILTER ===
startDate = timestamp(2020, 1, 1, 0, 0)
isLive = time >= startDate
// === ADX REGIME DETECTION ===
[plusDI, minusDI, adx] = ta.dmi(adxLen, adxSmooth)
isTrending = adx > adxThreshold
isRanging = not isTrending
regimeLabel = isTrending ? "TRENDING" : "RANGING"
// === EMA TREND FILTER ===
ema = ta.ema(close, emaLen)
bullish = close > ema
bearish = close < ema
biasLabel = bullish ? "Bullish" : "Bearish"
// === RSI MEAN REVERSION ===
rsi = ta.rsi(close, rsiLen)
rsiLong = isLive and isRanging and rsi < rsiBuy and bullish
rsiShort = isLive and isRanging and rsi > rsiSell and bearish
rsiLongExit = rsi > exitRSI
rsiShortExit = rsi < exitRSI
// === BREAKOUT ENTRIES ===
atr = ta.atr(atrLen)
highestBreak = ta.highest(close[1], breakoutLen)
lowestBreak = ta.lowest(close[1], breakoutLen)
longBreak = isLive and isTrending and bullish and close > highestBreak
shortBreak = isLive and isTrending and bearish and close < lowestBreak
// === ENTRIES ===
if rsiLong
strategy.entry("RSI Long", strategy.long)
if rsiShort
strategy.entry("RSI Short", strategy.short)
if longBreak
strategy.entry("Breakout Long", strategy.long)
if shortBreak
strategy.entry("Breakout Short", strategy.short)
// === EXITS ===
if rsiLongExit
strategy.close("RSI Long")
if rsiShortExit
strategy.close("RSI Short")
strategy.exit("RSI Long Exit", from_entry="RSI Long", stop=close - atr * stopMult)
strategy.exit("RSI Short Exit", from_entry="RSI Short", stop=close + atr * stopMult)
strategy.exit("BO Long Exit", from_entry="Breakout Long", trail_points=atr * atrMult, trail_offset=atr * atrMult)
strategy.exit("BO Short Exit", from_entry="Breakout Short", trail_points=atr * atrMult, trail_offset=atr * atrMult)
// === DEBUG PLOTS ===
plotshape(rsiLong, title="RSI Long", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(rsiShort, title="RSI Short", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
plotshape(longBreak, title="Breakout Long", location=location.belowbar, color=color.blue, style=shape.triangleup, size=size.small)
plotshape(shortBreak, title="Breakout Short", location=location.abovebar, color=color.purple, style=shape.triangledown, size=size.small)
plot(rsi, "RSI", color=color.blue)
plot(ema, "200 EMA", color=color.orange)
// === DASHBOARD ===
var label dash = na
if bar_index % 5 == 0
label.delete(dash)
dash := label.new(bar_index, high,
"Regime: " + regimeLabel + " | Bias: " + biasLabel + " | Last: None",
xloc=xloc.bar_index, yloc=yloc.price,
style=label.style_label_left, size=size.small,
textcolor=color.white, color=color.black)