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.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

