RSI Divergence Indicator (with alerts)
May 31, 2020

The RSI Divergence Indicator (with alerts) indicator is a comprehensive technical analysis tool designed to identify regular and hidden bullish or bearish divergences between price and the Relative Strength Index (RSI). This tool assists traders in spotting potential trend reversals and continuations by highlighting discrepancies in momentum while providing integrated alert functionality for timely trade execution.
Usage
The indicator plots various divergence types directly on the RSI oscillator and colors chart bars to signal trade opportunities and exits.
- Bullish Entry: A "Bull" or "H Bull" label appears when a bullish divergence is detected. On the chart, these are often marked with yellow bars. Traders may use these as signals to enter or add to long positions.
- Bearish Entry: A "Bear" or "H Bear" label indicates bearish momentum shifts.
- Exits: The script provides exit signals based on RSI overbought/oversold levels or opposite divergence signals. Purple (fuchsia) bars typically indicate a long exit signal.
- Bar Coloring: The indicator changes bar colors based on the active state (e.g., Yellow for Buy, Purple/Fuchsia for Exit). Note that since the indicator relies on pivot points, signals are confirmed and plotted with a delay defined by the Lookback Right setting.
Details
The script identifies four types of divergences:
- Regular Bullish: Price makes a lower low while RSI makes a higher low (reversal).
- Hidden Bullish: Price makes a higher low while RSI makes a lower low (continuation).
- Regular Bearish: Price makes a higher high while RSI makes a lower high (reversal).
- Hidden Bearish: Price makes a lower high while RSI makes a higher high (continuation).
The implementation uses pivot highs and lows to anchor divergence lines. The "Pivot Lookback" settings determine the window required to confirm a local peak or trough. Because pivots require bars to form to the right of the point, there is an inherent lag of several bars before the signal appears on the chart.
Settings
RSI Settings
- RSI Period: The number of bars used to calculate the RSI (default is 5).
- RSI Source: The price data used for the RSI calculation (default is Close).
Pivot Settings
- Pivot Lookback Right: The number of bars to the right of a pivot point required for confirmation.
- Pivot Lookback Left: The number of bars to the left of a pivot point required for identification.
Exit Settings
- Take Profit at RSI Level: The RSI threshold (e.g., 75) that triggers an exit signal for long positions.
- Take Profit at RSI Level (Short): The RSI threshold (e.g., 25) that triggers an exit signal for short positions.
Divergence Visibility
- Max/Min of Lookback Range: Defines the search window (in bars) between two pivots to qualify for a divergence.
- Plot Bullish/Hidden Bullish/Bearish/Hidden Bearish: Toggles the visibility of specific divergence types and labels on the oscillator.
FAQ
How do I interpret the delayed signals? Because the indicator uses pivots, a signal can only be confirmed after a specific number of bars (defined by Pivot Lookback Right) has passed. This ensures the pivot point is a valid local high or low.
Why are the bars changing color? The bar coloring represents the current logic state: Yellow indicates a buy entry signal, while Fuchsia indicates an exit signal for long positions.
How can I access this indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.