Overview
The RSI Multi-Signal Dynamic Trend Quantitative Strategy is a trend-following approach based on multiple dimensions of RSI indicator signals, primarily utilizing bullish divergences and hidden bullish divergences in the RSI oversold zone for long positions. This strategy integrates various classic methods from technical analysis, including RSI indicator judgment, price pattern recognition, trend following, and risk control. The core of the strategy is to capture market rebound opportunities after oversold conditions by identifying divergences between the RSI indicator and price movements, while setting dynamic exit conditions and risk control measures to achieve quantitative trading with controlled risk.
Strategy Principles
The core principles of this strategy are based on the following key mechanisms:
RSI Oversold Zone Signal Recognition: The strategy uses the Relative Strength Index (RSI) as its primary indicator. When the RSI value falls below 30, the market is considered oversold, presenting a potential opportunity for long positions.
Multiple Divergence Detection Mechanism: The strategy implements two types of divergence detection:
- Standard Bullish Divergence: Forms when RSI creates higher lows (rsiValue > rsiValue[i]) while price creates lower lows (low[i] < low[i * 2])
- Hidden Bullish Divergence: Forms when RSI creates lower lows (rsiValue < rsiValue[i]) while price creates higher lows (low[i] > low[i * 2]) Dynamic Search Range: Instead of using a fixed period for divergence detection, the strategy dynamically searches for divergence signals within a user-defined range (from lookbackMin to lookbackMax), significantly improving signal reliability.
Multi-condition Entry Logic: The strategy generates long signals only when the RSI value is below 30 and either type of divergence is detected. This dual filtering mechanism effectively reduces false signals.
Flexible Exit Mechanism: The strategy combines multiple exit conditions:
- RSI Filter-based Exit: Exits when the RSI value rises above 40 and the position has been held for the minimum required period
- Stop Loss Control: Forces exit when the price falls more than the set stop loss percentage (default 10%) from the entry point
Minimum Holding Period Protection: By setting a minimum holding period (holdBarsMin), the strategy prevents premature exits due to short-term market noise, ensuring the trend has sufficient space to develop.
Strategy Advantages
Multi-dimensional Signal Confirmation: Combining RSI oversold conditions and two types of divergence signals forms a multi-layer filtering mechanism, significantly improving the reliability of entry signals and reducing losses from false breakouts.
Dynamic Parameter Optimization: All key parameters of the strategy can be flexibly configured through the input parameter window, including RSI length, divergence detection range, profit-taking and stop-loss percentages, and minimum holding period, enabling the strategy to adapt to different market environments and trading instruments.
Comprehensive Risk Management: The built-in percentage-based stop-loss mechanism strictly controls the maximum loss for a single trade, avoiding excessive losses due to individual trades and protecting account capital safety.
Visualized Trading Assistance: The strategy provides rich visualization elements, including RSI zone background coloring, trade signal markers, and key indicator level lines, allowing traders to intuitively monitor strategy operating status and assess market conditions.
Intelligent Capital Management: The strategy uses a percentage of account equity for position management, with a default of 10% of account equity per trade, ensuring automatic adjustment of position size as the account size changes, achieving compound growth.
Trend Confirmation Exit: Unlike simple reversal signal exits, this strategy requires the RSI to rise above 40 before considering an exit, meaning it waits for the uptrend to be confirmed before exiting, effectively capturing most of the profit from the trend.
Strategy Risks
False Signal Risk in Oscillating Markets: In range-bound oscillating markets, RSI may frequently enter the oversold zone and form divergences, but prices may not form effective rebounds, resulting in multiple small losses. The solution is to adjust the RSI length parameter or add additional market environment filtering conditions in oscillating market environments.
Parameter Sensitivity Risk: Strategy performance is sensitive to key parameters such as RSI length and divergence detection range. Inappropriate parameter settings may result in too many or too few signals. It is recommended to find robust parameter combinations through backtesting across different timeframes and market environments.
Single Indicator Dependency Risk: The strategy primarily relies on the RSI indicator for decision-making, which may fail in certain special market environments. Consider adding other independent indicators such as moving averages, volume indicators, or volatility indicators as confirmation signals.
Rapid Decline Gap Risk: Although the strategy has stop-loss protection, in extreme market conditions, prices may gap or flash crash, causing actual stop-loss levels to deviate from expectations. Consider dynamically adjusting stop-loss percentages based on market volatility, or using derivatives such as options for additional protection.
Frequent Trading Cost Risk: With certain parameter combinations, the strategy may generate too many trading signals, leading to high trading costs that erode profits. This can be addressed by increasing signal confirmation thresholds or extending the minimum holding period to reduce trading frequency.
Strategy Optimization Directions
Multi-timeframe Analysis Integration: The current strategy analyzes RSI divergences within a single timeframe. Consider integrating signals from multiple timeframes, such as only trading when the trend direction is consistent across larger timeframes, to improve signal quality. This can be implemented by introducing trend determination functions for longer cycles.
Adaptive Parameter Mechanism: Consider dynamically adjusting RSI length and divergence detection range based on market volatility. Use shorter RSI periods in high-volatility market environments to improve response speed, and longer periods in low-volatility environments to reduce noise. This can be implemented by calculating ATR (Average True Range) and establishing parameter mapping relationships.
Volume Confirmation Addition: Incorporate volume analysis into the signal confirmation system, confirming divergence signals only when supported by volume, effectively filtering out invalid divergences. This can be implemented by detecting relative volume changes during divergence formation.
Dynamic Profit-Taking Mechanism: The current strategy uses fixed RSI conditions for exit. Consider implementing a trailing stop function that dynamically adjusts the profit-taking level as prices rise to lock in more profits. This can be triggered by calculating the percentage retracement from new price highs.
Machine Learning Optimization: Apply machine learning methods to automatically identify the best divergence patterns and parameter combinations. By training models with historical data, the accuracy and robustness of divergence judgment can be improved, reducing the subjectivity of manual parameter setting.
Risk Parity Allocation: Consider allocating different position ratios based on the historical success rate of different divergence types, allocating more funds to divergence types with higher success rates and cautiously configuring funds for less reliable divergence types, improving overall capital efficiency.
Summary
The RSI Multi-Signal Dynamic Trend Quantitative Strategy is a comprehensive quantitative trading system based on the RSI technical indicator. By capturing the divergence relationship between RSI and price, combined with multiple entry conditions and flexible exit mechanisms, it achieves efficient long operations in oversold market environments. The core advantages of this strategy lie in its multi-dimensional signal filtering system and comprehensive risk control mechanisms, maintaining a high win rate while effectively controlling individual trade risk.
The main risks of the strategy come from its dependence on a single indicator and parameter sensitivity. Future optimization directions should focus on multi-timeframe analysis, adaptive parameter adjustment, and multi-indicator comprehensive decision-making. Through these optimizations, the strategy's robustness and adaptability can be further improved, enabling it to maintain stable performance across more market environments.
For quantitative traders, this strategy provides a complete framework for understanding and applying RSI divergence trading. It can be used as an independent trading system or as a component of more complex systems, complementing other strategies. Through continuous parameter optimization and risk management improvements, this strategy has the potential to achieve stable risk-adjusted returns in long-term trading.
Strategy source code
/*backtest
start: 2024-06-02 00:00:00
end: 2025-06-02 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("GStrategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === Parameters ===
rsiLength = input.int(14, title="RSI Length")
lookbackMin = input.int(15, title="Divergence Lookback Min")
lookbackMax = input.int(35, title="Divergence Lookback Max")
tp = input.int(150, title="Take Profit %")
sl = input.int(10, title="Stop Loss %")
holdBarsMin = input.int(2, title="Minimum Bars to Hold")
// === Indicators ===
rsiValue = ta.rsi(close, rsiLength)
// === RSI Levels and Background ===
hline(70, title="Overbought", color=color.red, linestyle=hline.style_dashed)
hline(30, title="Oversold", color=color.green, linestyle=hline.style_dashed)
hline(50, title="Middle", color=color.gray, linestyle=hline.style_dotted)
bgcolor(rsiValue > 70 ? color.new(color.red, 90) : rsiValue < 30 ? color.new(color.green, 90) : na)
// === Precompute all pivot lows ===
pivotLows = array.new_bool(lookbackMax + 1)
for i = lookbackMin to lookbackMax
pl = not na(ta.pivotlow(rsiValue, i, i))
array.set(pivotLows, i, pl)
// === Divergence Detection ===
var bool divFound = false
divFound := false
for i = lookbackMin to lookbackMax
plFound = array.get(pivotLows, i)
bullDiv = plFound and rsiValue > rsiValue[i] and low[i] < low[i * 2]
hiddenBullDiv = plFound and rsiValue < rsiValue[i] and low[i] > low[i * 2]
if bullDiv or hiddenBullDiv
divFound := true
// === Entry Conditions (Long only) ===
longCondition = rsiValue < 30 and divFound
if longCondition
strategy.entry("Long", strategy.long)
// === Bar Counter While in Trade ===
var int barsInTrade = na
if strategy.position_size != 0
barsInTrade := nz(barsInTrade) + 1
else
barsInTrade := 0
// === Exit Conditions ===
exitCondition = (barsInTrade >= holdBarsMin) and (rsiValue > 40)
// === Close Position on Exit Condition ===
if exitCondition
strategy.close("Long", comment="Exit by Trend Filter")
// === Visualize Entry and Exit Points ===
plotshape(strategy.position_size > 0 and strategy.position_size[1] == 0, title="Long Entry", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Buy")
plotshape(strategy.position_size[1] > 0 and strategy.position_size == 0, title="Long Exit", location=location.abovebar, color=color.red, style=shape.xcross, size=size.small, text="Close")
// === RSI Chart ===
plot(rsiValue, title="RSI", color=color.purple, linewidth=2)
Strategy parameters
The original address: RSI Multi-Signal Dynamic Trend Quantitative Strategy
Top comments (1)
Great strategy! The dynamic RSI approach with multiple signals is a smart way to capture trends while reducing false entries. I like how it adapts to different market conditions. Have you tested it across various timeframes and assets? Also, curious if adding a volatility filter (like ATR) could improve performance during choppy markets. Solid work overall! 👏