All indicators

RSI Divergence Strategy

Dec 7, 2022

Static chart image
SignalsOscillatorsDivergencesMoney ManagementTrailing-Stop

The RSI Divergence Strategy indicator provides a systematic approach to trading Relative Strength Index (RSI) divergences by automating signal generation and trade management. It identifies potential market reversals by detecting discrepancies between price action and RSI momentum, offering a complete framework with built-in risk management tools.

Usage

The strategy can be used for various trading styles, from scalping to swing trading, depending on the selected timeframe and input parameters. When a bullish divergence is detected (price making lower lows while RSI makes higher lows), the script generates a buy signal. Conversely, a bearish divergence (price making higher highs while RSI makes lower highs) triggers a sell signal.

The strategy manages positions independently for long and short trades:

  • Long Entries: The quantity of the trade is proportional to the current RSI value.
  • Short Entries: The quantity is proportional to the value of 100 minus the RSI.
  • Trade Management: Users can define specific Take Profit, Stop Loss, and Trailing Stop percentages for both buy and sell groups to optimize risk-reward ratios.

Details

The script utilizes a linear regression-based approach to identify the trend of both the RSI and the price over a specified "RSI Divergence Length." By comparing the slopes of these two calculated lines, the script determines if a divergence exists.

  • A Bullish Divergence is identified when the price trend line is declining while the RSI trend line is ascending.
  • A Bearish Divergence is identified when the price trend line is ascending while the RSI trend line is declining. The script also includes a "Zoom" feature which adjusts the visual scale of the indicator on the chart pane without affecting the underlying mathematical results or strategy logic.

Settings

General Settings

  • RSI Length: Determines the lookback period for the RSI calculation.
  • Source: The price data used for the RSI (e.g., Close, Open, HL2).
  • RSI Divergence Length: The period over which the divergence trend lines are calculated.
  • Zoom: Adjusts the vertical scale of the indicator for better visual clarity.

Buy Group

  • Take Profit: The percentage target for closing long positions in profit.
  • Stop: The percentage at which long positions will be closed to limit losses.
  • Trailing Stop: The percentage offset for the trailing stop-loss mechanism on long trades.

Sell Group

  • Take Profit: The percentage target for closing short positions in profit.
  • Stop: The percentage at which short positions will be closed to limit losses.
  • Trailing Stop: The percentage offset for the trailing stop-loss mechanism on short trades.

FAQ

How do I access RSI Divergence Strategy?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Can this strategy be used for scalping?

Yes, the default settings are optimized for shorter-term scalp strategies, though they can be adjusted for any timeframe.

Does the Zoom setting change the backtest results?

No, the Zoom setting only affects the visual representation of the indicator on your chart and does not alter the entry or exit logic.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.