MACD, short for Moving Average Convergence Divergence, measures the distance between two exponential moving averages of price and then smooths that distance again to produce a signal line. Gerald Appel developed it in the late 1970s and the standard settings have barely moved since: a 12 period EMA, a 26 period EMA and a 9 period EMA of the difference. Everything else you have read about MACD is interpretation layered on top of those three numbers.
The name is literal, which is unusual for a technical indicator, and reading it literally solves most of the confusion. MACD is not measuring momentum in the physics sense and it is not measuring strength. It is measuring the gap between two smoothed prices, and the rate at which that gap is changing.
The formula
An exponential moving average weights recent data more heavily using a smoothing factor of 2 divided by (N + 1). For the three periods MACD uses, that gives the multipliers below.
| Component | Period | Smoothing factor | Applied to |
|---|---|---|---|
| Fast EMA | 12 | 0.1538 | Closing price |
| Slow EMA | 26 | 0.0741 | Closing price |
| Signal Line | 9 | 0.2000 | The MACD Line |
The update rule is the same for all three: new EMA equals the previous EMA plus the smoothing factor multiplied by (current value minus previous EMA). The signal line is the only one that takes the MACD Line rather than price as its input, which is why it always trails.
import pandas as pd
def macd(close, fast=12, slow=26, signal=9):
ema_fast = close.ewm(span=fast, adjust=False).mean()
ema_slow = close.ewm(span=slow, adjust=False).mean()
line = ema_fast - ema_slow
sig = line.ewm(span=signal, adjust=False).mean()
return line, sig, line - sig
df["macd"], df["signal"], df["hist"] = macd(df["close"])A worked example
Five bars, with the two price EMAs already computed so the interesting arithmetic is visible. The signal line uses a smoothing factor of 0.2, and the first signal value is seeded at 0.70.
| Bar | EMA 12 | EMA 26 | MACD Line | Signal Line | Histogram |
|---|---|---|---|---|---|
| 1 | 101.20 | 100.10 | 1.10 | 0.70 | 0.40 |
| 2 | 101.55 | 100.28 | 1.27 | 0.81 | 0.46 |
| 3 | 101.80 | 100.50 | 1.30 | 0.91 | 0.39 |
| 4 | 101.60 | 100.66 | 0.94 | 0.92 | 0.02 |
| 5 | 101.30 | 100.75 | 0.55 | 0.84 | 0.29 negative |
Follow bar 2 by hand to confirm the mechanics. The MACD Line is 101.55 less 100.28, which is 1.27. The signal line is the previous 0.70 plus 0.2 multiplied by (1.27 less 0.70), giving 0.814. The histogram is 1.27 less 0.814, or 0.46.
Now look at the sequence. The histogram peaks on bar 2 at 0.46 and shrinks from bar 3 onward, but the signal line crossover does not happen until bar 5. The histogram turned three bars before the cross. That is the entire practical argument for watching the histogram rather than the crossover, and also the entire practical argument against it, because a shrinking histogram very often recovers without a cross ever occurring.
The histogram
The histogram plots MACD Line minus Signal Line as bars around zero. It was not part of Appel’s original presentation. Thomas Aspray introduced it and wrote about its use in Technical Analysis of Stocks & Commodities magazine, and it has been standard on charting platforms ever since.
What it actually shows is the second derivative of the underlying relationship: not whether the EMAs are diverging, but whether that divergence is accelerating or decelerating. A histogram above zero and growing means the fast EMA is pulling away faster. Above zero and shrinking means the move is losing pace while still being an uptrend by every other MACD measure. Crossing zero is identical to a signal line crossover, so it adds nothing new at that exact moment.
The four common readings
| Reading | What it means mechanically | Main weakness |
|---|---|---|
| Signal line cross | MACD Line crosses its own 9 period EMA | Fires constantly in a range, always late in a trend |
| Zero line cross | The 12 and 26 period EMAs have swapped order | Slower than the signal cross, so entries are worse |
| Divergence | Price makes a new extreme, MACD does not | Persists for many bars, resolves without reversal often |
| Histogram turn | Rate of divergence starts falling | Earliest and noisiest of the four by a wide margin |
Notice that the four are ordered from latest to earliest, and that lateness and reliability move together. There is no configuration that gives you both. Choosing among them is choosing where on that tradeoff you want to sit, and the correct answer depends on your holding period and your tolerance for false starts, not on which one is objectively best.
What MACD cannot tell you
Three limitations are structural rather than fixable by tuning.
It lags by construction. Every component is an average of past prices, and the signal line is an average of an average. By the time a crossover prints, a meaningful part of the move has already happened. Shortening the periods reduces the lag and increases the false signals in exact proportion.
It has no fixed scale. MACD is expressed in the price units of the instrument, so a reading of 2.40 means something entirely different on a 40 dollar stock than on a 4,000 dollar index. You cannot compare MACD values across securities, and a level that looked extreme last year may be ordinary after the price has doubled.
It sees only closing prices. Gaps, intrabar ranges and volume are all invisible to it. A volatility measure such as Average True Range or a flow measure such as the Money Flow Index covers information MACD is structurally blind to.
What the evidence supports
Be skeptical of any article that quotes a MACD win rate without naming the market, the sample period and the transaction cost assumption. Those numbers are almost always produced by fitting a rule to a chart after the fact.
The peer reviewed picture is genuinely mixed. Brock, Lakonishok and LeBaron found statistically significant results for simple moving average and range breakout rules on the Dow between 1897 and 1986, published in the Journal of Finance in 1992. Sullivan, Timmermann and White then re ran that same rule universe in the Journal of Finance in 1999 using a bootstrap that corrects for data snooping, and the apparent edge did not hold in the period following the original sample. Bajgrowicz and Scaillet applied a false discovery rate framework in the Journal of Financial Economics in 2012 and reached a comparable conclusion once realistic costs were applied. Park and Irwin’s survey counted 95 modern studies, 56 positive, 20 negative, 19 mixed, and flagged data snooping as the central problem with that tally.
MACD is a moving average crossover rule with extra smoothing, so it sits squarely inside the family those papers examined. Treat it as a compact description of trend state and rate of change, which it does well, rather than as a source of edge.
Common problems and fixes
| Problem | Cause | Fix |
|---|---|---|
| Your values differ from the platform | EMA seeded differently, or adjust=True in pandas | Set adjust=False and discard the first 50 or so bars. |
| Crossovers every few bars | The market is ranging | Add a trend filter and ignore crosses near the zero line. |
| Divergence signal failed repeatedly | Strong trends produce continuous divergence | Require price structure confirmation before acting on it. |
| MACD unreadable after a stock split | Price units changed, history not adjusted | Use a split adjusted series, or use percentage price oscillator instead. |
Frequently asked questions
What are the best MACD settings?
12, 26 and 9 remain the default and there is no evidence that alternatives are better in general. Faster settings such as 5, 35 and 5 produce earlier and noisier signals. Pick a configuration before testing and hold it fixed, because tuning periods against past data is the fastest route to a backtest you cannot trade.
What is the difference between MACD and the histogram?
The MACD Line is the gap between two price EMAs. The histogram is the gap between the MACD Line and its own signal line. The histogram therefore turns earlier, since it reacts to changes in the rate of divergence rather than to the divergence itself.
Does MACD work on intraday charts?
The math applies to any bar interval, but the signal to noise ratio degrades sharply below about 15 minutes, because the EMAs are then dominated by microstructure rather than direction. If you use it intraday, add a session filter and expect far more false crossovers than on daily bars.
Is MACD a leading or lagging indicator?
Lagging. Every input is a moving average of past closes, so it can only describe what has already happened. The histogram is sometimes called leading because it turns before the crossover, but that is leading relative to the crossover, not relative to price.
Should I combine MACD with other indicators?
Yes, provided you add something that measures a different thing. Pairing MACD with another moving average system gives you two views of the same information. Pairing it with volatility bands such as Keltner Channels or with a projected structure like the Ichimoku Cloud is more informative.
The bottom line
MACD earned its place because it compresses a lot into one panel: trend direction from the zero line, trend strength from the distance, and rate of change from the histogram. The arithmetic is three exponential averages and two subtractions, and you can verify any bar of it by hand in under a minute.
It is also late by design, unbounded in scale, and blind to volume and gaps. Those are not settings problems. Use MACD to describe where a trend stands, use other tools to decide whether to act, and do not trust a published win rate that arrives without a dataset attached.
