All indicators

Histogram (MACD) with Divergences

Oct 16, 2019

Static chart image
SignalsOscillatorsDivergencesPivot Based (Retrospective)

The Histogram (MACD) with Divergences indicator focuses on two distinct MACD histograms and a multi-period divergence detection system to identify early trend shifts and potential support/resistance zones. By utilizing two histograms with different sensitivities, it provides a layered view of market momentum alongside automated pivot-based divergence signals.

Usage

This tool is designed to provide both short-term trade signals and long-term trend context through two specific components:

  • Histogram (1): Represented by a bright green/red line, this uses a shorter calculation period (default 1, 7). It acts as a fast-response momentum oscillator. Crossovers of the zero line can serve as early entry or exit signs.
  • Histogram (2): Represented by a shaded area, this uses a longer slow length (default 49). It defines the broader market trend; green areas indicate bullish momentum, while orange areas suggest bearish conditions.
  • Zero-Line Crosses: When Histogram (2) crosses the zero line, a green or red cross is plotted. These points often coincide with price levels that act as future support or resistance.
  • Divergence Signals: The indicator automatically plots regular and hidden divergences across three lookback periods (Long, Medium, and Short).
    • Green Triangles: Bullish Divergences.
    • Red Triangles: Bearish Divergences.
    • White Triangles: Hidden Divergences (Trend continuation).

The tool can be applied to standard candlestick charts, Line charts, or Heikin Ashi candles for varied smoothing effects.

Details

The script calculates two separate MACD sets based on a single "Fast Length" but two different "Slow Lengths". The resulting histograms are the difference between these MACDs and their smoothed signal lines.

Divergence detection is based on pivot highs and lows. The "Sensitivity" setting determines the lookback for comparing these pivots to price action. Users can toggle which histogram (Fast or Slow) serves as the source for divergence calculations, allowing for either high-frequency or high-conviction signals.

Settings

Core Parameters

  • Fast Length: The period for the fast moving average.
  • Slow Length: The period for the first histogram's slow moving average.
  • Slow Length 2: The period for the second (area) histogram's slow moving average.
  • Signal (=Smoothing): The smoothing period applied to the MACD lines.
  • Use SMA instead of EMA: Toggles between Simple Moving Averages and Exponential Moving Averages for all calculations.

Divergences

  • Sensitivity Divergences: Adjusts the lookback window for identifying divergence peaks/troughs.
  • Source Divergences: Selects whether Histogram 1 or Histogram 2 is used to calculate divergences.
  • Show Long/Medium/Short Period: Toggles for different lookback lengths (Left/Right bars).
  • Show Hidden Divergences: Toggles the display of trend-continuation (hidden) divergence signals.

FAQ

How do I interpret the different triangle sizes?

The size and style of the triangles correspond to the period length (Long, Medium, Short) defined in the settings, allowing you to distinguish between major and minor momentum shifts.

Can I see the actual MACD and Signal lines?

Yes, while they are set to 100% transparency by default to focus on the histogram, you can adjust their visibility in the "Style" tab of the indicator settings.

How do I access Histogram (MACD) with Divergences?

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.