All indicators

Divergence Indicator with alerts

Apr 27, 2021

Static chart image
SignalsDivergencesPivot Based (Retrospective)

The Divergence Indicator with alerts tool simplifies the detection of regular and hidden divergences between price action and any selected technical indicator to help traders identify potential trend reversals or continuations.

Usage

To use the tool, apply your preferred oscillator (e.g., RSI, MACD, or TSI) to the chart. Then, add the Divergence Indicator with alerts and set the "Indicator" source in the settings to the plot of your chosen oscillator. The script will then automatically monitor for divergences.

Users can choose to display the divergences directly on the oscillator or on the price chart by toggling the "Plot on price" option. Labels and connecting lines identify four types of divergences:

  • Regular Bullish: Price makes a lower low while the indicator makes a higher low.
  • Hidden Bullish: Price makes a higher low while the indicator makes a lower low.
  • Regular Bearish: Price makes a higher high while the indicator makes a lower high.
  • Hidden Bearish: Price makes a lower high while the indicator makes a higher high.

Details

The script utilizes pivot points to identify significant highs and lows in both price and the selected source indicator. It calculates divergences based on the relationship between the current pivot and the previous one within a specified lookback range.

A unique feature of this implementation is the "Delay plot until candle is closed" option. This setting ensures that divergences are only confirmed and plotted once the pivot right-hand lookback is finalized and the bar is closed, effectively removing real-time repainting of historical signals. The script also includes built-in alert conditions for all divergence types, allowing for automated notifications when specific conditions are met.

Settings

  • Plot on price (rather than on indicator): When enabled, the divergence lines and labels are drawn on the price candles instead of the oscillator pane.
  • Indicator: The source input used for divergence calculation (usually set to an external oscillator's plot).
  • Pivot Lookback Right: The number of bars to the right of a pivot point required for confirmation.
  • Pivot Lookback Left: The number of bars to the left of a pivot point required for confirmation.
  • Max of Lookback Range: The maximum number of bars to look back for the previous pivot point.
  • Min of Lookback Range: The minimum number of bars to look back for the previous pivot point.
  • Plot Bullish / Hidden Bullish / Bearish / Hidden Bearish: Toggles the visibility of specific divergence types.
  • Delay plot until candle is closed: Prevents signals from appearing on the current unconfirmed bar to avoid repainting.

FAQ

How do I set up alerts for specific divergences?

You can access the alert menu in TradingView and select "Divergence Indicator with alerts" as the condition. From there, you can choose specific alerts like "Regular Bullish Divergence" or "Any Divergence."

Can I use this with any indicator?

Yes, you can use any indicator that outputs a plot. In the "Indicator" source setting, simply select the desired output from any other indicator currently loaded on your chart.

Where can I find 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

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