Divergences (any input)
Aug 15, 2019

The Divergences (any input) indicator identifies bullish and bearish divergences by comparing price action against multiple underlying data sources, helping traders spot potential trend reversals.
Usage
The tool is used to detect discrepancies between price and technical oscillators or volume metrics. When the price makes a new low but the indicator shows a higher low (or vice versa), a divergence signal is plotted on the chart.
Example scenarios:
- Bullish Divergence: A green label appears below the bar when the script detects a bullish divergence across a sufficient number of sources based on the user-defined threshold.
- Bearish Divergence: A red label appears above the bar when a bearish divergence is confirmed across the inputs.
Users can modify the logic to incorporate different technical indicators (like RSI, MACD, or Accumulation/Distribution) by adjusting the source inputs in the script code.
Details
The script utilizes pivot point logic to identify significant highs and lows in both price and the secondary data sources. It evaluates multiple lookback periods (the last three identified pivots) to determine if a divergence exists.
A unique aspect of this tool is its modularity; it calculates divergences for multiple pairs (e.g., Price vs. RSI and Price vs. Accumulation/Distribution) and sums these occurrences. If the total number of detected divergences meets or exceeds the Div Threshold, a signal is triggered.
Settings
- Pivot Strength: Determines the number of bars required on each side of a high or low to qualify it as a pivot point. Higher values result in more significant but fewer signals.
- Div Threshold: Sets the minimum number of concurrent divergences required across the different source inputs to plot a signal on the chart.
FAQ
How do I use this indicator? You can apply the indicator to your chart and look for the colored labels. A green label indicates a bullish divergence, while a red label indicates a bearish divergence.
Can I add my own indicator inputs? Yes, the script is designed so that users can modify the "Main" section of the code to include any series (like MFI, CMF, or custom oscillators) as a basis for divergence detection.
How can I get access to Divergences (any input)? 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.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.