Divergence RSI
Jun 25, 2020

The Divergence RSI indicator scans for regular and hidden divergences between price action and the Relative Strength Index (RSI) to identify potential market reversals or trend continuations.
Usage
The indicator identifies four primary types of divergence, each marked with specific labels on the RSI oscillator:
- Regular Bullish (D): Occurs when the price makes a lower low while the RSI makes a higher low. This suggests a potential bullish reversal.
- Hidden Bullish (H): Occurs when the price makes a higher low while the RSI makes a lower low. This often indicates bullish trend continuation.
- Regular Bearish (D): Occurs when the price makes a higher high while the RSI makes a lower high. This suggests a potential bearish reversal.
- Hidden Bearish (H): Occurs when the price makes a lower high while the RSI makes a higher high. This often indicates bearish trend continuation.
Traders can use these signals to find entry points where momentum deviates from price movement. The labels are offset to align with the pivot points identified by the lookback settings.
Details
The script utilizes pivot point detection (ta.pivotlow and ta.pivothigh) to identify significant peaks and troughs in the RSI. It then compares these points with the corresponding price peaks and troughs.
- Lookback Logic: The indicator checks if a previous pivot occurred within a user-defined range (
Min/Max of Lookback Range). - Validation: Signals are confirmed once the "Right Lookback" period has passed, ensuring the pivot point is historically significant within the local window.
Settings
- RSI Source: Determines the price data used to calculate the RSI (default is close).
- RSI Period: The number of bars used for the RSI calculation.
- Pivot Lookback Right: The number of bars to the right of a pivot to confirm its validity.
- Pivot Lookback Left: The number of bars to the left of a pivot to confirm its validity.
- Max of Lookback Range: The maximum distance (in bars) to look for a previous pivot to compare for divergence.
- Min of Lookback Range: The minimum distance (in bars) to look for a previous pivot.
- Plotting Toggles: Individual checkboxes to enable or disable the display of Regular Bullish, Hidden Bullish, Regular Bearish, and Hidden Bearish signals.
FAQ
How do I interpret the "D" and "H" labels?
"D" stands for Divergence (Regular), which typically signals a potential trend reversal. "H" stands for Hidden Divergence, which typically signals a potential trend continuation.
Why do signals appear several bars late?
The indicator uses pivot lookbacks to confirm peaks and troughs. The signal will appear once the "Pivot Lookback Right" number of bars has closed to ensure the pivot is valid.
How can I get access to the Divergence RSI?
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.