MACD Indicator: Formula, What 12, 26, 9 Means, and the Signal Line Rule on Real Prices
Appel’s MACD from its documented formula: the 12 and 26 EMA gap, the 9-period signal line, where Aspray’s histogram came from, and what buying every signal line cross gave on a year of the S&P 500 ETF.
On this page
MACD, the Moving Average Convergence Divergence, is the gap between a 12-period and a 26-period exponential moving average of the close. Gerald Appel created it in the late 1970s. A 9-period average of MACD, the signal line, is drawn on top, and the difference between the two, the histogram, was added later. The three pieces give three readings: the sign of MACD, its crosses with the signal line, and divergences with the price. Below, the formula, what “12, 26, 9” means, and what the signal line crosses gave on a year of the daily S&P 500 ETF.
MACD(12, 26, 9) on the daily S&P 500 ETF
- Price, daily candles (hollow up, filled down)
- MACD, EMA(12) − EMA(26) (solid line)
- Signal, EMA(9) (solid line, second color)
- Histogram, MACD − signal
How MACD is calculated
MACD is a moving average difference: when the 12-period average is above the 26-period average, MACD is positive and the shorter-term trend is up. The signal line smooths MACD itself, and the histogram shows how far MACD is from its signal line.
StockCharts credits the histogram to Thomas Aspray, who “developed the MACD-Histogram to anticipate signal line crossovers in MACD.” His own first version, which he writes he completed in the fall of 1986 and presented in Stocks and Commodities in August 1988, was not quite the one platforms draw today: he describes it as “a 10-day momentum (with 3-day smoothing) of the MACD in histogram form.” The modern histogram is simply MACD minus its signal line.
The histogram crosses zero when MACD crosses its signal line
How to read MACD
| Signal | What happens | Usual reading |
|---|---|---|
| Signal line cross | MACD crosses its 9-period average; the histogram changes sign | Up: bullish; down: bearish |
| Centerline cross | MACD changes sign: the 12 EMA crosses the 26 EMA | Above zero: shorter trend up |
| Divergence | Price makes a new high or low that MACD does not confirm | The move may be weakening |
Signal line crosses and histogram sign changes are the same event: the histogram is zero exactly when MACD equals its signal line. A shrinking histogram only says a cross is getting closer, which was Aspray’s point. On divergence, see our dedicated page.
What 12, 26, 9 means, and why it matters
The three numbers are the fast average, the slow average and the signal average. They are a convention, not a law: Aspray himself wrote that by changing them “the results are dramatically different.” On the daily S&P 500 ETF, over the 250 days from October 30, 2025 to October 28, 2026, the standard 12, 26, 9 gave 23 signal line crosses and 12 zero line crosses. A faster 8, 17, 9 gave 27 and 21, and a 5, 35, 5 setting gave 40 and 16.
Crosses on the same 250 days, by MACD setting
- Signal line crosses
- Zero line crosses
On this window, shortening the two price averages to 8 and 17 added nine zero line crosses and four signal line crosses, and the 5, 35, 5 setting nearly doubled the signal line crosses. The relation is not smooth: with 12 and 26, a 5-period signal line gave the same 23 crosses as the 9-period one, and a 3-period one gave 38. More crosses mean more trades, each paying costs, with no guarantee that the extra signals are better ones.
The signal line rule on real prices
We applied the simplest MACD rule, long only, to the same window: buy at the close of an upward signal line cross, sell at the close of the next downward cross. On October 30, 2025, the first day of the window, MACD was already above its signal line, from a buy on October 24 at 670.02; that trade was sold on November 5 at 670.35, +0.05%. The trades opened inside the window follow; results are computed on unrounded closes, so the last digit can differ from a division of the closes shown.
| Buy | Close | Sell | Close | Result |
|---|---|---|---|---|
| November 28, 2025 | 676.10 | December 16 | 671.62 | −0.66% |
| December 23 | 682.63 | January 2, 2026 | 677.88 | −0.70% |
| January 6, 2026 | 686.45 | January 16 | 686.30 | −0.02% |
| January 28 | 690.03 | January 30 | 686.61 | −0.50% |
| February 2 | 690.02 | February 3 | 684.19 | −0.85% |
| February 25 | 687.78 | March 2 | 681.06 | −0.98% |
| April 2 | 652.52 | May 18 | 734.93 | +12.63% |
| July 6 | 749.42 | July 17 | 741.45 | −1.06% |
| August 3 | 755.79 | August 20 | 760.71 | +0.65% |
| September 21 | 773.50 | September 30 | 762.63 | −1.41% |
| October 2 | 769.64 | October 15 | 771.79 | +0.28% |
The 11 signal line trades opened in the window
Three of the 11 trades won, four of the 12 if the trade open at the window start is counted. The 11 compound to +6.85% before costs, against +14.83% for buying and holding from 672.57 to 772.31. All of the gain, and more, came from one trade, the April 2 buy near the spring low, held for six weeks of rally: it made +12.63% on its own, and without it the other ten trades compounded to −5.13%. The eight losses were small, six of them under 1%: many quick exits in the sideways months, and one trend that paid for them.
Does it work?
We have no long-run measurement of MACD: our bench tests chart patterns detected by rule against random entries, not indicators (see our methodology). The trades above are one market over one year, worked through to show how the rule behaves, not a test. A fair test would run fixed MACD rules on many markets and decades, with costs, against a random entry and against a plain moving average crossover, which MACD is built on.
For other momentum tools, see the RSI, the stochastic oscillator, or the full list of momentum indicators.
Frequently asked questions
How do you use the MACD indicator?
Look at three things: whether MACD is above or below zero, which says if the 12-period average is above the 26-period one; when it crosses its signal line; and whether it confirms new price highs and lows. Each is a description of momentum, not a guarantee of the next move.
What does 12, 26, 9 mean in MACD?
A 12-period EMA minus a 26-period EMA gives the MACD line, and a 9-period EMA of that line is the signal line. Changing the numbers changes the number of signals: on the daily S&P 500 ETF over 250 days, 12, 26, 9 gave 23 signal crosses, 8, 17, 9 gave 27, and 5, 35, 5 gave 40.
Which is better, MACD or RSI?
Neither in general. MACD follows the trend of two averages and has no fixed range; RSI is bounded from 0 to 100 and is often read for stretched levels. They can be shown together, but both are computed from the same closes.
What is the best indicator to use with MACD?
There is no measured answer. Combining MACD with another indicator built on the same closes, such as a moving average, adds little new information; volume tools such as on-balance volume at least use different data.
Who invented the MACD histogram?
Thomas Aspray, who presented it in Stocks and Commodities in August 1988 as a way to anticipate signal line crosses. His original version was a smoothed momentum of MACD; today it is drawn as MACD minus its signal line.
