What it measures
MACD stands for moving average convergence divergence, which is a description of what it watches: two averages drawing together and moving apart. When the fast average is above the slow one, the MACD line is above zero. When they cross, it is zero.
It is a measure of pace, not of level. A price that climbs by the same amount every bar gives a flat MACD line, because the two averages stay the same distance apart. The line moves when the pace changes.
The line is credited to Gerald Appel, in the late 1970s; the histogram was added later, and is usually credited to Thomas Aspray in 1986. The numbers 12, 26 and 9 are the settings they are published with, and most charts keep them.
How it is calculated, step by step
- 01
Calculate a fast EMA of the closes.
Usually 12 bars. EMA = close × k + previous EMA × (1 − k), with k = 2 ÷ (N + 1).
- 02
Calculate a slow EMA of the closes.
Usually 26 bars, the same way.
- 03
Subtract.
MACD line = fast EMA − slow EMA. It is in the same unit as the price.
- 04
Average the MACD line.
Signal line = EMA of the MACD line, usually over 9 bars.
- 05
Subtract again.
Histogram = MACD line − signal line. It is the bars drawn around zero.
The histogram is an average of a difference of averages: three layers of smoothing. Each layer adds delay. As with any EMA, programs differ in how they start the averages, so early values can disagree.
A worked example, by hand
Six closes: 10, 12, 11, 13, 16, 14. Small settings so it fits on a page: fast 2, slow 3, signal 2.
- Fast EMA (k = 2 ÷ 3), starting at bar 2 from (10 + 12) ÷ 2 = 11: then 11, 12.33, 14.78, 14.26
- Slow EMA (k = 0.5), starting at bar 3 from (10 + 12 + 11) ÷ 3 = 11: then 12, 14, 14
- MACD line from bar 3: 11 − 11 = 0; 12.33 − 12 = 0.33; 14.78 − 14 = 0.78; 14.26 − 14 = 0.26
- Signal (k = 2 ÷ 3), starting at bar 4 from (0 + 0.33) ÷ 2 = 0.17: then 0.78 × 0.667 + 0.17 × 0.333 = 0.57; then 0.26 × 0.667 + 0.57 × 0.333 = 0.36
- Histogram, to three places: 0.333 − 0.167 = 0.167; 0.778 − 0.574 = 0.204; 0.259 − 0.364 = −0.105
The last close fell from 16 to 14. The MACD line is still above zero (the fast average is still above the slow one), but the histogram has gone negative: the gap has started to close.
The numbers in this example were chosen to be easy to add up. They are not prices of anything.
How people read it
- Above or below zero. Above zero the fast average is above the slow one, which is the same information as a moving-average crossover, drawn differently.
- The line against its signal. The line crossing above the signal means the distance between the averages is growing faster than its own recent average; crossing below, the reverse.
- The histogram. Growing bars mean the gap between line and signal is widening; shrinking bars mean it is narrowing. It turns before the line crosses, because it is the distance to that crossing.
- Divergence. The price makes a new high and the MACD line does not. It is read as a rise losing pace.
What it cannot tell you
- It cannot lead the price. Every part of it is an average of closes that have already happened, and each layer of averaging adds delay.
- It cannot say that a market is ‘overbought’. It has no upper or lower limit, and its size depends on the price of the instrument.
- It cannot be compared between instruments, or between far-apart years of the same one, without adjusting for price. A MACD of 2 on a price of 2,000 is a much smaller thing than a MACD of 2 on a price of 20.
- It cannot tell a trend from a range. In a sideways market the line and the signal cross repeatedly, and every crossing looks alike.
Common mistakes
- Calling a crossing of the signal line a buy or sell signal. It is a statement about two averages of past prices, and it arrives after the move that caused it.
- Reading the height of the histogram as strength without looking at the scale. The scale changes with the price and with the settings.
- Counting it as independent of a moving-average crossover. It is made from the same averages, so the two agree by construction.
- Changing 12, 26 and 9 until the past looks tidy.
Questions people ask
- What do 12, 26 and 9 mean in MACD?
- They are three lengths, in bars. The MACD line is a 12-bar exponential moving average of the close minus a 26-bar one. The signal line is a 9-bar exponential moving average of the MACD line. The histogram is the MACD line minus the signal line. The numbers are the settings it was published with, kept by convention.
- Is a MACD crossover a buy signal?
- It is a description, not an instruction. When the MACD line crosses above its signal line, the gap between the fast and slow averages has been growing. That has already happened by the time it shows, and what follows can go either way. In a sideways market such crossings are frequent and mean little.
- What is the difference between MACD and RSI?
- Both describe the pace of recent price changes. RSI compares average rises with average falls and is confined to a scale of 0 to 100. MACD is the distance between two moving averages, has no limits and is in the unit of the price. They often agree, because they are made from the same closes.
The words on this page
An indicator is arithmetic on prices that have already happened. It describes what a price did; it does not predict what a price will do. The chart on this page is invented: a seeded random walk, not a market. This page is an explanation for study. It is not advice, a recommendation or a forecast, and nothing an indicator shows says anything certain about what a price will do next.
