All indicators

MACD Indicator

Sep 1, 2020

Static chart image
SignalsOscillatorsDivergences

The MACD Indicator tool provides a comprehensive technical analysis suite based on the Moving Average Convergence Divergence, offering users a centralized interface for trend identification and momentum exhaustion.

Usage

The script can be used to identify trend changes through MACD and Signal line crossovers, while the histogram provides insights into the strength of the current momentum. Users can customize the display to show only specific elements, such as the MACD/Signal lines, the Histogram, or the unique "MACD Leader" component.

Example use cases include:

  • Crossover Identification: Utilizing the built-in Buy and Sell signals (blue and red circles) which appear when the MACD crosses the Signal line with confirmed momentum.
  • Divergence Trading: Monitoring for Regular (R) or Hidden (H) divergences plotted directly on the oscillator to identify potential trend reversals or continuations.
  • Visual Trend Confirmation: Enabling bar coloring based on MACD status to align price action with oscillator momentum.

Details

This implementation allows for significant flexibility by supporting both EMA and SMA calculation methods for the underlying moving averages. Beyond the standard MACD calculation, it includes a "MACD Leader" line designed to react more dynamically to price changes. The divergence detection logic uses a fractal-based lookback system (comparing peaks and troughs) to identify discrepancies between price action and the oscillator values. Divergences can be calculated based on the Histogram, MACD line, or the MACD Leader line.

Settings

  • MA Type: Choose between EMA (Exponential) or SMA (Simple) for the internal calculations.
  • Fast / Slow Length: Adjust the periods for the two moving averages that form the MACD.
  • Source: The price data used for calculations (default is close).
  • Signal Smoothing: The period for the Signal line moving average.
  • Display Toggles: Individual checkboxes to show/hide the MACD, Signal, Histogram, MACD Leader, and Buy/Sell signals.
  • Bar Color: Options to color price bars based on Cross signals, MACD position, or to disable it.
  • Divergence Method: Select which component (Hist, MACD, or MACDL) is used to calculate divergences.
  • Divergence Type: Choose to display Regular, Hidden, Both, or no divergences.
  • Show Label: Toggle the "R" and "H" labels on the oscillator.

FAQ

How do I interpret the divergence labels? Labels marked with "R" indicate Regular Divergence, which often signals a potential trend reversal. Labels marked with "H" indicate Hidden Divergence, which typically suggests a trend continuation.

Can I set alerts for specific signals? Yes, the script includes alert conditions for MACD crossovers, specific Buy/Sell signals, and all types of detected divergences.

How can I access this indicator? 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.