All indicators

Divergence MACD Sign/Alert [MsF]

Aug 21, 2022

Static chart image
SignalsOscillatorsDivergencesMoving Averages

The Divergence MACD Sign/Alert [MsF] indicator detects and visualizes bullish and bearish divergences between price action and the MACD oscillator to identify potential trend reversals or continuations.

Usage

The script is used to identify moments where the momentum of the market (represented by the MACD) deviates from the price action. It supports both regular and hidden divergences across three different oscillator types: the main MACD line, the Signal line, or the Histogram.

  • Regular Bullish Divergence ("D"): Occurs when the price makes a lower low but the oscillator makes a higher low. This suggests a potential upward reversal.
  • Regular Bearish Divergence ("D"): Occurs when the price makes a higher high but the oscillator makes a lower high. This suggests a potential downward reversal.
  • Hidden Bullish Divergence ("H"): Occurs when the price makes a higher low but the oscillator makes a lower low, suggesting a continuation of the uptrend.
  • Hidden Bearish Divergence ("H"): Occurs when the price makes a lower high but the oscillator makes a higher high, suggesting a continuation of the downtrend.

The indicator plots these labels directly on the oscillator sub-window for clear visibility.

Details

The script utilizes pivot point detection to identify local highs and lows in both price and the chosen oscillator. By comparing these pivots within a specific lookback window (defaulting to 8 bars for pivot detection and a range of 5 to 60 bars for the divergence lookback), the script determines if the relationship between price and momentum is consistent.

Users can choose which component of the MACD calculation to analyze for divergence. This provides flexibility, as some traders prefer the sensitivity of the Histogram while others prefer the smoother MACD or Signal lines.

Settings

MACD Parameters

  • Fast Length: The period for the short-term EMA calculation (default: 12).
  • Slow Length: The period for the long-term EMA calculation (default: 26).
  • Signal Smoothing: The EMA period used to smooth the MACD line into the Signal line (default: 9).
  • Osc Type: Selects which value to check for divergence: MACD, SIGNAL, or HISTOGRAM.

Detection Settings

  • Lookback Bars: Defines the strength of the pivot by specifying the number of bars required on either side of the pivot point.

Visibility Settings

  • Plot Bullish: Toggles the display of Regular Bullish divergence labels.
  • Plot Hidden Bullish: Toggles the display of Hidden Bullish divergence labels.
  • Plot Bearish: Toggles the display of Regular Bearish divergence labels.
  • Plot Hidden Bearish: Toggles the display of Hidden Bearish divergence labels.

FAQ

How do I use the Divergence MACD Sign/Alert [MsF]?

Select your preferred oscillator component (MACD, Signal, or Histogram) in the settings and monitor the sub-window for "D" (Regular) or "H" (Hidden) labels which indicate potential trading opportunities.

Can I set alerts for these signals?

Yes, the script includes built-in alert conditions for both bullish and bearish signals (covering both regular and hidden types) which can be configured through the TradingView alert menu.

How can I access Divergence MACD Sign/Alert [MsF]?

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.