Skip to main content
Module 08 · Technical Analysis

MACD

5 min readYou'll be able to Compute the MACD line, signal line and histogram from 12-, 26- and 9-period EMAs, and read crossovers, the zero line and divergence as trend context with known lag.

MACD — Moving Average Convergence Divergence — measures the gap between a fast and a slow exponential moving average of price. When the fast average pulls away above the slow one, upward momentum is building; when the gap narrows, momentum is fading. A second average of that gap (the signal line) and the difference between the two (the histogram) make changes in momentum easier to see, but everything in MACD is built from moving averages, so it always lags price.

MACD
Quick demo

Updating MACD for three bars (hypothetical numbers). Yesterday: EMA(12) = 104.80, EMA(26) = 103.50, signal line = 1.20. The multipliers are 2 ÷ 13 = 0.1538 for the 12-EMA, 2 ÷ 27 = 0.0741 for the 26-EMA and 2 ÷ 10 = 0.20 for the 9-period signal.

Bar 1 — close 108.70.

  • EMA(12) = 104.80 + 0.1538 × (108.70 − 104.80) = 105.400
  • EMA(26) = 103.50 + 0.0741 × (108.70 − 103.50) = 103.885
  • MACD = 105.400 − 103.885 = 1.515
  • Signal = 1.20 + 0.20 × (1.515 − 1.20) = 1.263
  • Histogram = 1.515 − 1.263 = +0.252

Bar 2 — close 104.00. EMA(12) = 105.185, EMA(26) = 103.894, MACD = 1.291, signal = 1.269, histogram = +0.022 — momentum has almost stalled.

Bar 3 — close 103.00. EMA(12) = 104.849, EMA(26) = 103.827, MACD = 1.021, signal = 1.219, histogram = −0.198. The MACD line has crossed below the signal line.

Note that MACD is still above zero at 1.021: the 12-EMA remains above the 26-EMA, so the medium-term trend is still up even though short-term momentum has turned.

MACD histogram for the demo bars (arithmetic on hypothetical closes)
0.25Bar 10.02Bar 2-0.2Bar 3
  • Bar 3 — Histogram below zero: MACD crossed under its signal line.

Exact arithmetic from the demo's starting values and closes. Not real market data.

The three components

Gerald Appel developed MACD in the late 1970s; the histogram was added later and is now standard on every platform.

  1. MACD line = EMA(12) − EMA(26). Positive when the faster average is above the slower one.
  2. Signal line = 9-period EMA of the MACD line — a smoothed version of it.
  3. Histogram = MACD line − signal line. It shows whether the MACD line is pulling away from or converging toward its own average.

The defaults 12, 26 and 9 originated on daily charts. They are now used on every timeframe out of convention. Other settings exist, but changing them to make past signals look better is curve-fitting.

12
Fast EMA
Multiplier 2 ÷ 13 ≈ 0.1538
26
Slow EMA
Multiplier 2 ÷ 27 ≈ 0.0741
9
Signal EMA
Multiplier 2 ÷ 10 = 0.20
MACD − signal
Histogram
Positive when MACD is above its signal

Reading MACD

  • Zero line. MACD above zero = the 12-EMA is above the 26-EMA = an upward bias in the medium term. A cross through zero is a 12/26 EMA crossover.
  • Signal-line crossovers. MACD crossing above the signal line shows short-term momentum turning up; crossing below shows it turning down. A bullish crossover below zero happens during a downtrend; above zero, during an uptrend. The latter is in the direction of the larger trend.
  • Histogram. Because it is the difference between MACD and its average, the histogram turns before the lines cross. A shrinking histogram — like bar 2 in the demo — says momentum is fading, not that the trend has ended.

Divergence

As with RSI, divergence compares price swings to indicator swings. Price makes a higher high while the MACD line (or histogram) makes a lower high: the second push had less momentum. Divergence can repeat several times in a strong trend before price turns, or never lead to a turn. Treat it as a reason to tighten risk, and look for a break in price structure for confirmation.

Why MACD values are not comparable across markets

MACD is a difference between two prices, so it is in the instrument's price units. A MACD of 2.0 on a $40 stock is a big gap; on a $4,000 index it is tiny. The Percentage Price Oscillator (PPO) fixes this: PPO = (EMA(12) − EMA(26)) ÷ EMA(26) × 100. In the demo's bar 1, PPO = 1.515 ÷ 103.885 × 100 ≈ 1.46%. Use PPO when comparing momentum between instruments or across long periods in which price changed a lot.

Practical ways to use it

  1. As a trend filter: favour longs when MACD is above zero, shorts when below.
  2. To time pullback entries within a trend: in an uptrend (MACD above zero), a pullback that brings the MACD line down toward its signal or the histogram near zero, followed by a renewed upturn, shows momentum resuming.
  3. For risk management: a shrinking histogram or bearish divergence during a long trade is a reason to tighten the stop or take partial profit.

In every case, entries and stops come from price — swing highs and lows, support and resistance — not from the indicator value.

MACD across timeframes

The same 12/26/9 settings mean very different things on different charts. On a daily chart, the 26-period EMA covers about five weeks of trading; on a five-minute chart, a little over two hours. A bullish daily MACD and a bearish five-minute MACD are not in conflict — they describe different horizons.

A common approach is to read MACD on the timeframe above the one you trade for bias, and on your trading timeframe for timing. For example, a swing trader might only take long setups on the daily chart while the weekly MACD is above zero, and use the daily histogram turning up from a pullback to time entries. A day trader might do the same with an hourly chart for bias and a five-minute chart for timing.

Keep the pairing fixed. If you look at enough timeframes, one of them will always agree with the trade you already want to take.

Common mistakes

  • Trading every signal-line cross regardless of trend.
  • Comparing raw MACD values between different instruments.
  • Forgetting the lag: by the time the zero line crosses, much of the move may be over.
  • Treating divergence as a reversal signal without a price trigger.
  • Optimising the 12/26/9 settings to fit historical charts.
Check yourself

1. EMA(12) is 52.40 and EMA(26) is 51.10. The signal line is 1.00. What is the histogram?

2. The previous signal line is 0.50 and today's MACD is 1.00. What is today's signal line?

3. MACD crosses from below zero to above zero. What does that mean?

4. Why use PPO instead of MACD to compare momentum in a $20 stock and a $2,000 stock?