Momentum indicators

Moving Average Convergence/Divergence

Difference between fast and slow moving averages with signal and histogram outputs.

Engine
TA-Lib
Function
MACD
Input series
close
Outputs
3

How it works

MACD computes the difference between fast and slow moving averages of close, then computes a signal line over that MACD series. The histogram is the difference between MACD and the signal line.

Use case

Use MACD as a multi-output momentum and trend-change feature that captures moving-average convergence and divergence.

Parameters

ParameterTypeDefaultBounds or optionsDescription
Fast Periodinteger122…100000Period for the faster moving average.
Slow Periodinteger262…100000Period for the slower moving average.
Signal Periodinteger91…100000Period used to smooth the MACD line into the signal line.

Outputs

OutputTypeDescription
MACDnumberMACD line value for the bar.
MACD SignalnumberSignal line value for the bar.
MACD HistogramnumberDifference between the MACD line and signal line for the bar.

Reading the result

MACD describes the separation between a faster and a slower smoothed price baseline. Its signal output smooths that separation, while the histogram represents the difference between the main and signal lines.

Zero-line position, line crossings, histogram sign, and histogram change answer different questions. Preserve them as separate features instead of reducing the entire indicator to one crossover event.

Common mistakes

  1. Using a fast horizon that is not actually shorter than the slow horizon.
  2. Comparing raw MACD magnitude across assets with very different price levels.
  3. Treating histogram growth as direct price acceleration without considering the smoothing chain.
  4. Comparing implementations without identical source history and initialization.

DataCat workflow notes

MACD has several persisted outputs. Use the deterministic output mapping in indicator_definitions. If cross-asset comparability matters, create an explicitly normalized downstream feature rather than changing the raw DataCat output.

Resources

Search documentation

Search across 46 documentation pages.