All indicators

Divergence V2

Jun 12, 2023

Static chart image
Price Action BasedSignalsOscillatorsDivergences

The Divergence V2 indicator identifies and visualizes discrepancies between asset price movements and the RSI oscillator to highlight potential trend reversals.

Usage

The Divergence V2 tool is used to spot trend exhaustion by comparing price action against the Relative Strength Index (RSI). When a divergence occurs, the price typically follows the direction of the oscillator.

  • Bullish Divergence: Formed when the price records falling lows while the RSI shows rising lows. These are plotted with green lines on the chart.
  • Bearish Divergence: Formed when the price records rising highs while the RSI shows falling highs. These are plotted with red lines on the chart.

The indicator also features a labeling system that displays the number of occurrences found within a specific lookback period, allowing traders to gauge the frequency of divergent signals at a glance.

Details

The script executes a search for divergent points by calculating a linear relationship between two points in time for both price and RSI. It uses a "tolerance" logic to determine how many price bars are allowed to "pierce" the imaginary line connecting the two points of the divergence. This ensures that the identified trend line is significant rather than just a noise-filled connection. Additionally, the script includes a "Squeeze" parameter which integrates a linear regression oscillator to filter signals based on momentum trends.

Settings

  • Backtesting Bars: Determines the total number of bars back the indicator will scan for divergences.
  • Tolerance: Sets the maximum number of times a price bar can cross the divergence line (0-3). Lower values require a cleaner divergence.
  • Min Bars to Detect: The minimum horizontal distance (in bars) required between two points to qualify as a divergence.
  • Max Bars to Detect: The maximum horizontal distance (in bars) allowed between two points.
  • Source Highs: Defines the price source used for identifying bearish divergence peaks (Close or High).
  • Source Lows: Defines the price source used for identifying bullish divergence troughs (Close or Low).
  • Use Squeeze Parameter: When enabled, filters divergences to only show those coinciding with momentum favorable to the trend.

FAQ

How do I use the Tolerance setting? The Tolerance setting controls how strict the divergence line is. If set to 0, no bars can cross the line connecting the two divergence points. Increasing this allows for slight "noise" in the price action.

Can I use this for both Bullish and Bearish signals? Yes, the indicator automatically detects and colors green lines for bullish (buy) divergences and red lines for bearish (sell) divergences.

How do I access Divergence V2? 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.