MACD

Calculate the Moving Average Convergence Divergence (MACD) indicator, producing the MACD line, signal line, and histogram. The MACD rule measures the relationship between two moving averages of a data source, making it one of the most widely used tools for identifying trend direction, momentum shifts, and potential entry or exit signals.

How It Works

The MACD rule computes three values from a single source input:

  • MACD Value — The difference between a fast moving average and a slow moving average of the source. When the MACD line is positive, the fast average is above the slow average, indicating upward momentum. When negative, the fast average is below the slow average, indicating downward momentum.
  • Signal Value — A moving average of the MACD line itself, acting as a smoothed trigger line. Crossovers between the MACD line and the signal line are commonly used as trade entry and exit signals.
  • Delta Value — The difference between the MACD line and the signal line, also known as the MACD histogram. Positive delta values indicate bullish momentum (MACD above signal), while negative values indicate bearish momentum (MACD below signal). The magnitude of the delta shows the strength of the momentum.

Both the oscillator (fast and slow moving averages) and the signal line support configurable moving average types, allowing you to use any of the available algorithms: Simple, Exponential, Double Exponential, Running, Weighted, Hull, or Arnaud Legoux. When using the Arnaud Legoux type, the Shift and Sigma parameters control the Gaussian weighting curve.

Inputs

Input Description Required Default
Source The numeric data series used to calculate the MACD. Typically connected to a close price, but can be any numeric output such as another indicator value or a calculated result. Yes
Offset The number of bars to look back into the historical series before returning the values. An offset of 0 returns the current values, 1 returns the previous bar's values, and so on. No 0
Oscillator MA Type The moving average algorithm used for both the fast and slow moving averages that form the MACD oscillator. Available values: Simple, Exponential, Double Exponential, Running, Weighted, Hull, Arnaud Legoux. No Simple
Fast Length The number of data points (bars) used for the fast moving average. This shorter-period average responds more quickly to price changes. The standard setting is 12. No 12
Slow Length The number of data points (bars) used for the slow moving average. This longer-period average provides a smoother baseline. The standard setting is 26. No 26
Signal MA Type The moving average algorithm used to smooth the MACD line into the signal line. Available values: Simple, Exponential, Double Exponential, Running, Weighted, Hull, Arnaud Legoux. No Simple
Signal Length The number of data points (bars) used for the signal line moving average. The standard setting is 9. No 9
Shift Controls the offset of the Gaussian weighting curve when an Arnaud Legoux (ALMA) moving average type is selected. A value of 0 centres the weight on older data, 1 on newer data, and 0.85 is the standard default. No 0.85
Sigma Controls the width of the Gaussian weighting curve when an Arnaud Legoux (ALMA) moving average type is selected. Higher values create a broader, smoother curve. No 6.0

Outputs

Output Description List
MACD Value The MACD line value, calculated as the difference between the fast and slow moving averages. Positive values indicate the fast average is above the slow average (bullish momentum); negative values indicate the opposite (bearish momentum). No
Signal Value The signal line value, a smoothed moving average of the MACD line. Use crossovers between the MACD Value and Signal Value as trade timing signals. No
Delta Value The histogram value, calculated as the difference between the MACD Value and Signal Value. Positive delta indicates bullish momentum; negative delta indicates bearish momentum. Increasing magnitude signals strengthening momentum. No

Tips

Connect the MACD Value and Signal Value outputs to a Compare Switch rule to detect crossovers: when the MACD crosses above the signal line, it generates a bullish signal, and when it crosses below, a bearish signal. For stronger confirmation, use the Delta Value output and check that it is increasing in magnitude after a crossover. You can also use the Delta Value with a Compare Switch to detect when the histogram crosses above or below zero, which represents the same crossover event but is simpler to configure. For faster signals in volatile markets, try using the Exponential or Hull MA types for the oscillator instead of Simple.

Was this helpful? Let us know