RSI Divergence Tops + Bottoms
Oct 8, 2019

The RSI Divergence Tops + Bottoms indicator identifies local price peaks and troughs by detecting momentum divergences between price action and the Relative Strength Index (RSI).
Usage
The indicator highlights potential reversal points where the momentum of the market deviates from the price trend. It is used to identify:
- Potential Sell Points (Bearish Divergence): Occurs when the price achieves a higher high, but the RSI records a lower peak, suggesting weakening upward momentum.
- Potential Buy Points (Bullish Divergence): Occurs when the price achieves a lower low, but the RSI records a higher trough, suggesting weakening downward momentum.
Users can toggle specific plot types to clean up the chart or focus on particular signal types, such as regular peaks/troughs versus actual divergence signals. This tool is best utilized in conjunction with other technical analysis methods to confirm macro trend shifts.
Details
The script calculates a standard 14-period RSI and looks for specific structural patterns:
- Tops and Bottoms: Local extrema are identified by comparing the RSI value at a specific point against its neighbors. A peak is defined when the RSI is above 60 and follows a specific "mountain" shape, while a trough is defined below 40.
- Divergence Logic: The script stores the previous RSI peak/trough and the corresponding closing price. A divergence signal is triggered only if the current local extremum shows a price trend contradicting the RSI trend.
Settings
- Plot Overbought / Oversold Bands?: Toggles the visibility of the RSI levels (30, 50, 70, 90) and their associated background fills.
- Plot Potential RSI troughs?: Displays gray circles at all RSI local bottoms regardless of divergence.
- Plot Potential RSI peaks?: Displays gray circles at all RSI local tops regardless of divergence.
- Plot RSI Troughs Divergence?: Displays green circles when a bullish divergence is detected.
- Plot RSI Peak Divergence?: Displays red circles when a bearish divergence is detected.
FAQ
How do I access RSI Divergence Tops + Bottoms?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
What RSI period does this indicator use?
The script uses a standard 14-period Relative Strength Index (RSI) calculation using the RMA (Running Moving Average) method.
Can I use this for automated alerts?
Yes, the script includes built-in alert conditions that trigger on every bar close when a buy or sell divergence is detected.
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.