Indicator library · Trend
MACD, Moving Average Convergence Divergence
The distance between a fast moving average and a slow one, with an average of that distance drawn on top. Simple to compute, widely watched, and carrying one property that is routinely forgotten: its values are in the instrument’s own currency.
The calculation
- MACD line: EMA(12) − EMA(26) of the closing price. Positive when the faster average is above the slower one, which is to say when recent prices are above the longer trend.
- Signal line: EMA(9) of the MACD line. An average of an average, and therefore slower again.
- Histogram: MACD − signal, plotted as bars. It contains no information the two lines do not, but it makes the distance between them, and the rate at which that distance is changing, directly visible.
All three are differences of prices, which means the output is denominated in whatever the instrument trades in. That single fact explains most of the ways this indicator is misused, and it is covered again below because it matters more than the settings do.
Reading it
Zero-line crossings
MACD crossing zero means the fast average has crossed the slow one, the classic moving average crossover, expressed as one line instead of two. It is the slowest reading here and the most conservative.
Signal-line crossings
The most commonly quoted signal, and the one that generates the most noise. In a trend these crossings mark pullbacks and resumptions usefully; in a range they arrive every few bars and reverse immediately. Whether MACD "works" is very largely a question of whether the instrument was trending, which is not something the indicator can tell you.
Divergence
Price makes a higher high, MACD makes a lower one. Read exactly as on RSI: a statement that the second push was made with the two averages closer together than the first, which is worth noting and is not a trigger. The histogram makes this easier to see and correspondingly easier to imagine.
Where 12, 26 and 9 came from
Gerald Appel published the indicator in the late 1970s, and the three numbers are artefacts of the market he was working in rather than the output of an optimisation. A trading week was six sessions for part of the twentieth century, so 26 was about a month of bars and 12 about a fortnight; nine was roughly two weeks of the resulting difference.
None of that reasoning survives into a five-day week, and yet the settings should probably be left alone, for a reason that has nothing to do with their arithmetic. They are the default on virtually every charting platform, which means a very large number of participants are looking at the same line at the same time. That coordination is the only genuine property the specific numbers have, and it is lost the moment they are changed.
Which is also the case against tuning them. Adjusting the periods until the signals on a past chart look better trades away the one real advantage of the defaults for an improvement measured entirely on data you already have.
The currency problem, in numbers
MACD is a difference between two prices, so its output is denominated in whatever the instrument trades in. The consequence is easiest to see by taking one move and pricing it twice.
| Instrument | Move | Typical MACD reading |
|---|---|---|
| Stock at $500 | +8% over a month | Values in the tens of dollars |
| Stock at $50 | +8% over a month | Values around a tenth of those |
| Same $500 stock, after a 10:1 split | Unchanged in percentage terms | Entire history rescaled by a tenth |
Two conclusions follow directly, and both are routinely ignored. A MACD level remembered from before a split means nothing after it. And no absolute threshold, "MACD above 2 is strong". Can be transferred between instruments, or even between two eras of the same instrument at very different price levels. Where a comparable measure is needed, the percentage form of MACD, or an oscillator built from percentage change such as the Price Momentum Oscillator, answers the question this one cannot.
Where it misleads
| Situation | What goes wrong |
|---|---|
| Comparing instruments | Values carry the price level. A $500 stock produces far larger MACD readings than a $50 one making identical percentage moves. |
| Stock split | The entire history rescales. Levels remembered from before a split mean nothing after it. |
| Sideways market | Crossings every few bars, most immediately reversed, inherent to a difference of two lagging averages, not a settings problem. |
| Absolute thresholds | There is no overbought level. MACD is unbounded, and any fixed value applies to one instrument at one price level. |
| Histogram treated as new information | It is the gap between the two lines. Its zero crossing is the crossing, not an earlier one. |
What volume adds
A signal-line crossing tells you two averages of the closing price have changed places. It says nothing about participation, and the two cases it cannot separate are exactly the ones that matter: a crossing that occurs as volume expands and breadth confirms, and an identical crossing on the thinnest session of the month. The first describes a market changing direction; the second describes a few orders in a quiet book moving an average that had nearly caught up anyway.
Frequently asked questions
What do the numbers 12, 26 and 9 mean?
The lengths of three exponential moving averages: a fast one over 12 periods, a slow one over 26, and a 9-period average of the resulting difference, which is the signal line. Gerald Appel chose them in the late 1970s for daily charts, when a trading week was six days and 26 was roughly a month of sessions. There is nothing optimal about them; they persist because they are the default everywhere, which means a large number of participants are watching the same line.
Why can I not compare MACD values between stocks?
Because the output is a difference between two prices, so it carries the instrument’s price level with it. A $500 stock routinely produces MACD values ten times larger than a $50 stock making the same percentage moves. It is also why a stock split resets the whole history: the same company at a tenth of the price produces a tenth of the MACD. If you need to rank instruments, use something built from percentages, the rate of change or the Price Momentum Oscillator.
What does the histogram add?
It plots MACD minus its signal line, which turns a crossing into a measurable distance. The histogram crossing zero is the same event as the two lines crossing — no extra information — but the height tells you how far apart they are and, more usefully, the histogram shrinking while price still advances says the two averages are converging before the crossing arrives. That is the earliest reading available from this indicator and correspondingly the noisiest.
Is a signal-line crossing enough to trade on?
On its own, no. MACD is built from moving averages, so it inherits their behaviour: reliable in a sustained trend, and in a sideways market it produces crossings every few bars, most of which reverse immediately. This is not a tuning problem to be solved with different periods; it is what a difference of two lagging averages does when there is no trend for them to lag behind.
What is percentage MACD and should I use it?
It divides the difference of the two averages by the slower average, expressing the output as a percentage rather than in the instrument’s currency. That one change removes the property that causes most of the misuse: values become comparable between instruments and survive a stock split. It is sometimes called the percentage price oscillator. If your reason for wanting MACD is to rank or compare several instruments, use this form; if you are reading one chart, the ordinary version is fine and more widely quoted.
Which average should the signal line be taken from?
From the MACD line itself. It is a nine-period exponential average of the difference, not an average of price. Implementations sometimes get this wrong by averaging the closes again, which produces a line that looks plausible and crosses at different times. A quick check: with a flat price series the MACD line and its signal must both converge on zero, and any implementation where they do not is averaging the wrong input.
Does MACD work on intraday charts?
The arithmetic runs on any bar interval, and the periods mean bars rather than days, so 12/26/9 on a five-minute chart spans about two hours rather than a month. That is a legitimate thing to compute. The caution is that the standard settings were chosen for daily bars in the late 1970s, so their popularity, the coordination effect of many people watching the same line, does not transfer to an arbitrary intraday interval in the same way.
Why does the histogram sometimes shrink while price rises strongly?
Because the histogram measures the gap between the two averages, not the strength of the move. In a steady advance, both averages eventually settle into rising at a similar rate, the gap between them stops widening, and the histogram shrinks even though price is making new highs. Read as a warning it is frequently wrong; read as what it is (the two averages are no longer separating) it is simply accurate and often unremarkable.
How much history does MACD need?
More than the 26 bars the slow period suggests. Both components are exponential averages, which carry their whole history with a decaying weight, and the signal line is an average of an average, so the first values depend visibly on where the series starts. Feed at least a few hundred bars and read none of the first hundred if you need values that another implementation will reproduce.