RSI Divergence Method
Mar 26, 2023

The RSI Divergence Method indicator is a technical analysis tool designed to automatically identify and visualize regular and hidden divergences between price action and the Relative Strength Index (RSI). By leveraging advanced Pine Script features like methods and types, it provides a refined way to spot potential trend reversals and continuations through momentum shifts.
Usage
The indicator identifies two primary classes of divergence to assist in market analysis:
- Big Divergence (Regular Divergence): These appear when price makes a new extreme but the RSI fails to confirm it. A "Big Bull" occurs when price makes a lower low while RSI makes a higher low, signaling a potential bullish reversal. A "Big Bear" occurs when price makes a higher high while RSI makes a lower high, signaling a potential bearish reversal.
- Small Divergence (Hidden Divergence): These often suggest trend continuation. A "Small Bull" occurs when price makes a higher low while RSI makes a lower low. A "Small Bear" occurs when price makes a lower high while RSI makes a higher high.
The labels and lines are plotted with an offset to align with the pivot points where the divergence was confirmed. The "Big" signals are highlighted in standard green/red colors, while "Small" signals use contrast colors to distinguish them on the pane.
Details
The script utilizes a custom setup object to manage RSI data, pivot offsets, and lookback ranges efficiently. It determines divergences by comparing price pivots to RSI pivots within a user-defined lookback window (Min / Max). The implementation uses the ta.pivotlow and ta.pivothigh functions on the RSI series to ensure the signals are anchored to structural momentum turning points rather than simple candle-by-candle comparisons.
Settings
RSI
- Source / Length: Determines the price source (e.g., Close) and the period used to calculate the RSI.
Pivot Lookback
- Left / Right: Controls the number of bars required to the left and right of a point for it to be considered a valid pivot. Increasing these values results in fewer, more significant signals.
Lookback Range
- Min / Max: Defines the minimum and maximum distance (in bars) allowed between two pivots to qualify for a divergence.
Bull / Bear Filters
- Big | Small: Toggle switches to enable or disable the detection and plotting of Regular (Big) or Hidden (Small) divergences for both bullish and bearish directions.
FAQ
How do I use the RSI Divergence Method in my strategy?
It is best used as a confluence tool. Regular divergences (Big) suggest the current trend is losing momentum and may reverse, while hidden divergences (Small) suggest the trend has enough strength to continue after a pullback.
Why do signals appear a few bars late?
The indicator relies on pivot points, which require "Right Bars" to confirm a peak or trough. This delay ensures the structural point is valid before a signal is plotted.
How can I access this tool?
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.