rsi divergences [RSI side]
May 8, 2020

The rsi divergences [rsi side] indicator identifies regular bullish and bearish RSI divergences by comparing price action pivots with Relative Strength Index (RSI) peaks and troughs.
Usage
This tool is designed to be used in conjunction with the corresponding "chart side" script to provide a complete view of market divergences. It plots the RSI line along with historical divergence lines directly on the oscillator pane.
A regular bullish divergence occurs when the price makes a lower low, but the RSI makes a higher low, suggesting weakening bearish momentum. Conversely, a regular bearish divergence occurs when the price makes a higher high, but the RSI makes a lower high, suggesting weakening bullish momentum. The script can identify these patterns looking back up to five pivot levels, prioritizing the largest detected divergence to reduce chart clutter.
Details
The script uses pivot high and pivot low logic to identify significant turning points in both price and the RSI. By analyzing multiple lookback levels (1 through 5), the indicator can detect complex divergences that span across several price swings rather than just the most recent ones. It includes logic to filter and delete smaller overlapping divergence lines, ensuring that only the most significant structural divergence is displayed.
Settings
- How many right bars for pivots: Sets the number of bars required to the right of a peak or trough to confirm a pivot point.
- How many left bars for pivots?: Sets the number of bars required to the left of a peak or trough to confirm a pivot point.
- Pivot source for bear divs: The price source used to determine price-side pivot highs (default is Close).
- Pivots source for bull divs: The price source used to determine price-side pivot lows (default is Close).
- RSI length: The period used for the Relative Strength Index calculation.
- RSI overbought level: The upper threshold for the RSI oscillator.
- RSI oversold level: The lower threshold for the RSI oscillator.
- Show pivot highs?: Toggles the visibility of identified pivot high points.
- Show pivot lows?: Toggles the visibility of identified pivot low points.
- Lookback level for divs: Determines how many pivots back the script will search for a potential divergence (options 1 to 5).
FAQ
How do I use this script?
You should apply this script to your chart and ideally pair it with the "chart side" version of the indicator to see divergences mapped on both the price action and the RSI pane simultaneously.
What is the "Lookback level"?
The lookback level determines the depth of the search for divergences. For example, a level of 5 allows the script to compare the current pivot with any of the previous 5 pivots to find a valid divergence.
How can I get access to rsi divergences [rsi side]?
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.

