Indicator Guide / Momentum

MACDMoving Average Convergence/Divergence

The gap between a fast and a slow average of price, and whether that gap is growing or shrinking.

MACD 12, 26, 9 on a practice chartMade-up prices
Top: price. Bottom: the MACD line (purple), the signal line (orange) and the histogram bars between them.
01 · WHAT IT IS

MACD takes a fast 12-bar average of price and subtracts a slow 26-bar average. The result is the MACD line.

A 9-bar average of the MACD line is the signal line. The histogram bars show the gap between those two lines. When the MACD line is above zero, the fast average is above the slow one.

02 · UNDER THE HOOD
  • Fast average (12)
  • Slow average (26)
  • Price

Fast–

−

Slow–

=

MACD line–

Signal line–

Histogram–

The MACD line is the gap between the fast and slow averages of price. The shaded band is that gap. The signal line is a 9-bar average of the MACD line. The histogram bars show how far apart those two lines are.

How it is worked out

MACD line = 12-bar EMA of the closing price − 26-bar EMA. Signal line = 9-bar EMA of the MACD line. Histogram bars = MACD line − signal line. An EMA (exponential moving average) gives recent bars more weight. Each new bar counts for 2 ÷ (length + 1) of the new average.

03 · WHO MADE IT, AND WHY

“I was looking for a quality indicator that would be readily interpretable, that would not create so many whipsaws as to be confusing, and that would still be relatively simple to maintain.”

Appel, interviewed by Jayanthi Gopalakrishnan, Technical Analysis of Stocks & Commodities, September 2003.

Gerald Appel, Late 1970s. He dated it to about 1977. He wrote about it again in his 2005 book Technical Analysis: Power Tools for Active Investors. Appel started trading for himself in the mid-1960s. In 1973 he founded Signalert, an investment advisory firm. By 2003 its newsletter, Systems & Forecasts, had run for 30 years. In 1986 Thomas Aspray added the bars that show the gap between the MACD line and its signal line.

Whipsaws are signals that flip back and forth. MACD still makes them in sideways markets, as the charts below show.

04 · TWO TERRAINS
In a sideways market, the lines cross back and forth. Many crosses go nowhere. Traders call these whipsaws.Code picked this after the fact.
Trail · TrendStrong rise
In a sustained uptrend, the MACD line stays above zero. The fast average stays above the slow one.Code picked this after the fact.

Good for

  • Seeing trend and momentum in one place. When the MACD line is above zero, the fast average is above the slow one.
  • Seeing a move speed up or slow down. Taller histogram bars mean the two lines are farther apart.
  • Noticing when a move gets weaker. Price makes a new high, but MACD makes a lower high. This is a divergence.

Not good for

  • Overbought and oversold readings, meaning price has gone too far up or down. MACD has no top or bottom, so StockCharts says it is not particularly useful for that.
  • Comparing markets. MACD is in price units, so a high-priced stock shows bigger numbers than a cheap one. The Percentage Price Oscillator is the version for comparing.
  • Sideways markets. The lines cross back and forth, and many crosses go nowhere.
  • Early warnings. MACD is built from moving averages, so it lags price.
Where it fails

MACD lags, because it is built from moving averages. In sideways markets its lines cross back and forth. StockCharts also warns about divergences in strong trends. Divergences that point down are common in a strong uptrend that keeps going.

05 · TRY IT

On the chart below, find every time the MACD line crossed above its signal line. For each one, count the next 10 bars. Did price fall, go sideways or keep rising? On made-up prices, this shows you how to read the crosses. It does not test them.

Every cross above the signal line

  • 0Fell
  • 0Went sideways
  • 0Kept rising
Fell or kept rising: price moved more than 2% down or up after 10 bars. Went sideways: within 2%. Gold shading marks the 10 bars counted.Made-up prices. This shows how to read MACD. It does not show whether MACD works.
06 · SETTINGS AND MISTAKES
  • Fast12 barsAn exponential average of the closing price.
  • Slow26 barsAn exponential average of the closing price.
  • Signal9 barsAn exponential average of the MACD line.
  • Zero line0The fast and slow averages are equal.

Common mistakes

  • Taking every signal-line cross in a sideways market.
  • Reading a high MACD as overbought. MACD has no fixed top.
  • Comparing MACD numbers between two markets with different prices.
  • Treating a divergence as certain. In a strong trend, divergences are common.
07 · OUR TESTS

Not measured on our data yet. A Library episode will test Gerald Appel's MACD against a popular online version, with fees and held-out data.

Sources (8)
  1. StockCharts ChartSchool: MACDLate 1970s, 12/26/9, no top or bottom, price units and the Percentage Price Oscillator, zero-line crosses that became whipsaws when no strong trend followed, MACD above zero in a sustained uptrend, divergence warning
  2. Gerald Appel interview, Technical Analysis of Stocks & Commodities, September 2003Why he built MACD, in his words; about 1977; trading since the mid-1960s; Signalert and Systems & Forecasts, 1973
  3. Technical Analysis of Stocks & Commodities, V.21:9 (September 2003): Interview: Gerald AppelThe interview's issue and interviewer; Signalert is an investment advisory company
  4. Gerald Appel, Technical Analysis: Power Tools for Active Investors (2005), chapter 8Appel's own dating: late 1970s
  5. StockCharts ChartSchool: MACD-HistogramThomas Aspray developed the MACD-Histogram
  6. TradingView: MACDThomas Aspray added the histogram in 1986
  7. StockCharts ChartSchool: Moving averagesEMA weighting 2 ÷ (length + 1); worked example used to test our code
  8. Wikipedia: MACDFormula, lag, less useful in markets without a trend

Indicators are public ideas. The words here are ours, with credit to each source. Information, not advice.