All indicators

RSI Divergence Detector

Mar 8, 2026

Static chart image
SignalsOscillatorsDivergencesPivot Based (Retrospective)

The RSI Divergence Detector indicator automatically identifies bullish and bearish RSI divergences on the price chart to help traders spot potential momentum reversals.

Usage

The RSI Divergence Detector is primarily used to identify instances where price action and momentum (RSI) are out of sync, often preceding a change in trend direction. Labels are automatically plotted on the chart when a divergence is confirmed based on pivot points.

  • Bullish Divergence: This occurs when the price makes a lower low while the RSI makes a higher low. This suggests that despite the price drop, selling pressure is waning, potentially leading to an upward reversal.
  • Bearish Divergence: This occurs when the price makes a higher high while the RSI makes a lower high. This indicates that buying momentum is slowing down, suggesting a possible downward reversal.

Traders should note that because the indicator relies on pivot points for confirmation, signals will appear with a delay equal to the "Pivot Right Bars" setting.

Details

The script utilizes the Relative Strength Index (RSI) and pivot point calculations to find divergences. It tracks the most recent price and RSI pivots (highs and lows) and compares them to the current pivot values.

A divergence is confirmed if:

  1. For Bullish: The current price pivot low is lower than the previous one, but the current RSI pivot low is higher than the previous one.
  2. For Bearish: The current price pivot high is higher than the previous one, but the current RSI pivot high is lower than the previous one.

The calculation uses ta.pivotlow and ta.pivothigh functions, which require a specific number of bars to the left and right to confirm a peak or trough.

Settings

  • RSI Length: Determines the lookback period used to calculate the Relative Strength Index.
  • Pivot Left Bars: The number of bars required to the left of a candle to consider it a potential pivot point.
  • Pivot Right Bars: The number of bars required to the right of a candle to confirm it as a pivot point. Higher values result in more reliable but more delayed signals.

FAQ

How do I access the RSI Divergence Detector?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Why do the labels appear several bars after the actual price low or high?

The indicator uses pivots that require "Right Bars" confirmation. This means a low or high is only confirmed once a specific number of subsequent bars have closed, ensuring the pivot is valid.

Can I change the sensitivity of the detector?

Yes, by adjusting the Pivot Left and Right Bars settings. Smaller values will detect more frequent, shorter-term divergences, while larger values will focus on more significant, long-term trend shifts.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.