Divergence LinerRegressionSlope
Feb 5, 2020

The Divergence LinerRegressionSlope indicator automatically identifies and labels regular and hidden divergences between price action and the Linear Regression Slope oscillator to help traders spot potential trend reversals or continuations.
Usage
The tool plots a Linear Regression Slope (LRS) line in a separate pane. Divergences are identified when the momentum of the LRS contradicts the movement of price at key pivot points.
- Regular Bullish Divergence (D): Occurs when price makes a lower low, but the LRS makes a higher low. This suggests a potential bullish reversal.
- Hidden Bullish Divergence (H): Occurs when price makes a higher low, but the LRS makes a lower low. This often suggests a continuation of an uptrend.
- Regular Bearish Divergence (D): Occurs when price makes a higher high, but the LRS makes a lower high. This suggests a potential bearish reversal.
- Hidden Bearish Divergence (H): Occurs when price makes a lower high, but the LRS makes a higher high. This often suggests a continuation of a downtrend.
Details
The indicator calculates the Linear Regression Slope by taking the difference between the current linear regression curve value and its previous value. This creates an oscillator that fluctuates around a zero line, representing the rate of change in price trend.
The divergence logic utilizes pivot points (highs and lows) determined by a lookback window. When a pivot is confirmed, the script checks a user-defined range of previous bars to see if a prior pivot exists to form a valid divergence comparison.
Settings
- Slope Length: Sets the period for the Linear Regression calculation.
- LRS Source: Determines the price source (e.g., close, open) used for the calculation.
- 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 to find a preceding pivot for divergence.
- Min of Lookback Range: The minimum number of bars required between two pivots to qualify as a divergence.
- Plotting Toggles: Individual checkboxes to enable or disable the display of Regular Bullish, Hidden Bullish, Regular Bearish, and Hidden Bearish signals.
FAQ
How do I use the divergence labels?
"D" labels represent Regular Divergences, which typically indicate potential trend reversals. "H" labels represent Hidden Divergences, which are generally used to identify trend continuation opportunities.
Can I adjust the sensitivity of the signals?
Yes, by adjusting the "Pivot Lookback" and "Slope Length" settings, you can filter for more significant pivot points or change how reactive the underlying oscillator is to price changes.
How can I access Divergence LinerRegressionSlope?
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.