Momentum indicators

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.

· Founder of PatternsWizard
Checked 7 min read
MACD(12, 26, 9)
On this page
  1. How MACD is calculated
  2. How to read MACD
  3. What 12, 26, 9 means, and why it matters
  4. The signal line rule on real prices
  5. Does it work?
  6. Frequently asked questions

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

781.6703.9626.1017.54−13.03Oct 30, 2025Apr 30, 2026Oct 28, 2026
  • Price, daily candles (hollow up, filled down)
  • MACD, EMA(12) − EMA(26) (solid line)
  • Signal, EMA(9) (solid line, second color)
  • Histogram, MACD − signal
MACD(12, 26, 9) on S&P 500 ETF, dividend-adjusted prices, daily, October 30, 2025 to October 28, 2026. Illustration of how the indicator reads, not a backtest.

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

MACD and signal lineHistogram: MACD minus signalCross: the histogrampasses through zeroMACD lineSignal lineCross
Schematic, not market data. The standard settings, computed on an abstract wave, not on prices.The histogram is the gap between the two lines: it shrinks as they converge and passes through zero on the day they cross.

How to read MACD

SignalWhat happensUsual reading
Signal line crossMACD crosses its 9-period average; the histogram changes signUp: bullish; down: bearish
Centerline crossMACD changes sign: the 12 EMA crosses the 26 EMAAbove zero: shorter trend up
DivergencePrice makes a new high or low that MACD does not confirmThe 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

12, 26, 9 (standard)23128, 17, 927215, 35, 54016
  • Signal line crosses
  • Zero line crosses
Our computation; the inputs and the method are in the text.Daily S&P 500 ETF closes, dividend-adjusted, October 30, 2025 to October 28, 2026.

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.

BuyCloseSellCloseResult
November 28, 2025676.10December 16671.62−0.66%
December 23682.63January 2, 2026677.88−0.70%
January 6, 2026686.45January 16686.30−0.02%
January 28690.03January 30686.61−0.50%
February 2690.02February 3684.19−0.85%
February 25687.78March 2681.06−0.98%
April 2652.52May 18734.93+12.63%
July 6749.42July 17741.45−1.06%
August 3755.79August 20760.71+0.65%
September 21773.50September 30762.63−1.41%
October 2769.64October 15771.79+0.28%

The 11 signal line trades opened in the window

Nov 28 to Dec 16, 2025−0.66%Dec 23, 2025 to Jan 2, 2026−0.70%Jan 6 to Jan 16−0.02%Jan 28 to Jan 30−0.50%Feb 2 to Feb 3−0.85%Feb 25 to Mar 2−0.98%Apr 2 to May 18+12.63%Jul 6 to Jul 17−1.06%Aug 3 to Aug 20+0.65%Sep 21 to Sep 30−1.41%Oct 2 to Oct 15+0.28%
Our computation; the inputs and the method are in the text.MACD(12, 26, 9), long only, buy and sell at the close of the cross, daily S&P 500 ETF, no costs; dates in 2026 unless stated.

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.

Sources

  1. StockCharts ChartSchool, MACD (Moving Average Convergence/Divergence Oscillator)
  2. StockCharts ChartSchool, MACD-Histogram
  3. Thomas Aspray, MACD momentum Part 1, Stocks and Commodities V. 6:8, August 1988 (article listing with abstract)
, Founder of PatternsWizard

Passionate about finance, quantitative trading and data analysis. Amaury built the PatternsWizard test bench, which detects each pattern on full price history and measures what happened next against random entries.

PatternsWizard tests chart and candlestick patterns on full market history, against random entries. How we test patterns.

179 patterns testedRandom-walk self-test passed

All momentum indicators articles