Divergence RSI V2
Jun 12, 2023

The Divergence RSI V2 indicator is a specialized technical analysis tool designed to identify and visualize discrepancies between asset price movement and the Relative Strength Index (RSI) oscillator. By detecting these divergences, the script helps traders anticipate potential trend reversals where price action is likely to realign with the oscillator's momentum.
Usage
The Divergence RSI V2 can be used to spot both bullish and bearish reversals based on the relationship between price highs/lows and RSI peaks/troughs.
- Bullish Divergence: Occurs when the price makes a lower low, but the RSI makes a higher low. The indicator connects these points with a green line on the RSI pane.
- Bearish Divergence: Occurs when the price makes a higher high, but the RSI makes a lower high. The indicator connects these points with a red line on the RSI pane.
Labels are generated at the end of detected divergence lines, displaying a numerical count of occurrences found within the lookback period. This helps traders assess the frequency and validity of the signal over a specific timeframe.
Details
The script utilizes a linear interpolation function (valueInLine) to determine the path between two points and checks if the intervening price or RSI data "crosses" this line. This allows for a "Tolerance" setting, where the user can define how strictly the divergence must be formed without price action breaking the trendline.
Additionally, the script includes an optional "Squeeze Parameter." When enabled, it filters signals to only show divergences that coincide with specific momentum conditions derived from Bollinger Bands and Keltner Channels (Squeeze logic), ensuring that the signals align with broader volatility and trend shifts.
Settings
- Backtesting Bars: Limits the number of historical bars the indicator scans for divergences (maximum 1000 recommended for performance).
- Tolerance: The maximum number of times a price or RSI bar is allowed to cross the divergence line (range 0–3).
- Min Bars to Detect: The minimum distance (in bars) required between two points to qualify as a divergence.
- Max Bars to Detect: The maximum distance (in bars) allowed between two points for a divergence to be valid.
- Source Highs: Determines whether the high points are calculated based on the "Close" or "High" of the bars.
- Source Lows: Determines whether the low points are calculated based on the "Close" or "Low" of the bars.
- Use Squeeze Parameter: When enabled, filters for divergences that occur in alignment with momentum squeeze conditions.
FAQ
How do I interpret the lines and labels?
Green lines represent bullish divergences, suggesting potential upward price movement. Red lines represent bearish divergences, suggesting potential downward price movement. The numbers in the labels indicate the count of detected occurrences in the current lookback.
Can I use this for intraday trading?
Yes, the Divergence RSI V2 can be applied to any timeframe. Users should adjust the "Min/Max Bars to Detect" settings to suit the volatility of their chosen timeframe.
How do 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.