Skip to content

Indicator Formula

MACD calculates the difference between two EMAs and smooths it with a signal line.


Mathematical Derivation

Purpose: Measure the gap between fast and slow EMAs.

$$MACD = EMA(Close, fast) - EMA(Close, slow)$$

Where:

  • $$fast$$ = Fast period (default 12)
  • $$slow$$ = Slow period (default 26)

What This Measures: Momentum as the convergence/divergence of two EMAs


Purpose: Smooth the MACD for crossover signals.

$$Signal = EMA(MACD, signalPeriod)$$

Where:

  • $$signalPeriod$$ = Signal line period (default 9)

What This Measures: Smoothed momentum for timing crossovers



Compact Formula Summary

$$MACD = EMA(Close, 12) - EMA(Close, 26)$$ $$Signal = EMA(MACD, 9)$$

Defaults: Fast = 12, Slow = 26, Signal = 9


Complete Calculation Example

If EMA(12) = 45.80 and EMA(26) = 45.20: MACD = 45.80 - 45.20 = +0.60 If Signal = 0.45: MACD > Signal = bullish crossover


Key Takeaways from the Example
  1. MACD > 0: Fast EMA above slow EMA = bullish trend
  2. Signal Line Crossover: Timing signal for momentum shifts
  3. Histogram: Visual representation of crossover momentum