What does MACD show, and why does it lag?
Short answerMACD (moving average convergence divergence) shows the gap between a fast and a slow exponential moving average of closing prices, by default the 12-bar EMA minus the 26-bar EMA. When the gap is positive, recent prices are above older prices; when it widens, the trend is speeding up. In a steady trend, MACD settles at about 7 times the average price change per bar, so it is best read as a smoothed measure of trend speed in price units. A 9-bar EMA of MACD, the signal line, and their difference, the histogram, complete the indicator.
MACD lags because everything in it is an average of past closes. The MACD line turns only after price has turned, a signal-line crossover adds more smoothing, and a move below zero needs the fast average to fall below the slow one. On a straight-line test in this lesson, the signal-line crossover came 1 bar after the top and the zero crossing 15 bars after it. MACD's values are in the price units of the chart, so they cannot be compared across assets or price levels. Knowing what it measures explains why its signals arrive late and why a "divergence" can appear in a trend that keeps going.
Valmy noteValmy's v1 strategy language includes the simple moving average and no other indicator, so MACD is taught here for reading charts (as of 26 November 2026).
Moving average convergence divergence (MACD): the gap between two EMAs#
Moving average convergence divergence (MACD) measures how far a fast exponential moving average (EMA) of the close is above or below a slow one. It was created by Gerald Appel in the late 1970s. The standard settings are 12, 26 and 9, and it has three parts:
- MACD line = EMA(12) of the close − EMA(26) of the close. Positive when the fast average is above the slow one.
- Signal line = EMA(9) of the MACD line.
- Histogram = MACD line − signal line, drawn as bars around zero.
Its only input is the close, and every part is in the chart's price units, for example USDT on a BTC/USDT chart. Each EMA moves a fixed fraction α of the way toward its input at every bar, with α = 2 ÷ (n + 1): 0.1538 for 12 bars, 0.0741 for 26 and 0.2 for 9. The histogram is generally credited to Thomas Aspray, who wrote in Technical Analysis of Stocks & Commodities in 1988 that he completed his MACD histogram work in the fall of 1986. The names come from the two averages: they converge when the gap shrinks and diverge when it grows. This lesson uses EMAs that each start from a simple average of their first n inputs, so the MACD line first appears at bar 26 and the signal line at bar 34. TA-Lib aligns the start differently, as explained below.
Calculating MACD step by step#
The calculation is three EMAs and two subtractions. To keep the table short, this example uses MACD(3, 5, 3): α = 0.5 for the 3-bar EMAs and 1/3 for the 5-bar EMA. The standard 12, 26, 9 works the same way. The closes are invented (synthetic data). Each EMA starts from the simple average of its first n inputs.
| Bar | Close | EMA(3) | EMA(5) | MACD line | Signal, EMA(3) of MACD | Histogram |
|---|---|---|---|---|---|---|
| 1 | 100 | |||||
| 2 | 102 | |||||
| 3 | 104 | 102.00 | ||||
| 4 | 106 | 104.00 | ||||
| 5 | 108 | 106.00 | 104.00 | 2.00 | ||
| 6 | 109 | 107.50 | 105.67 | 1.83 | ||
| 7 | 109 | 108.25 | 106.78 | 1.47 | 1.77 | −0.30 |
| 8 | 108 | 108.13 | 107.19 | 0.94 | 1.35 | −0.41 |
| 9 | 106 | 107.06 | 106.79 | 0.27 | 0.81 | −0.54 |
| 10 | 104 | 105.53 | 105.86 | −0.33 | 0.24 | −0.57 |
- EMA(3) starts at bar 3 from (100 + 102 + 104) ÷ 3 = 102, then moves halfway to each close: bar 4 = 102 + 0.5 × (106 − 102) = 104.
- EMA(5) starts at bar 5 from (100 + 102 + 104 + 106 + 108) ÷ 5 = 104, then moves a third of the way: bar 6 = 104 + (109 − 104) ÷ 3 = 105.67.
- MACD line = EMA(3) − EMA(5): bar 5 = 106 − 104 = 2.00; bar 6 = 107.50 − 105.67 = 1.83.
- Signal line starts at bar 7 from the average of the first three MACD values, (2.00 + 1.83 + 1.47) ÷ 3 = 1.77, then moves halfway each bar: bar 8 = 1.77 + 0.5 × (0.94 − 1.77) = 1.35.
- Histogram = MACD − signal: bar 7 = 1.47 − 1.77 = −0.30.
The MACD line peaked at bar 5, while the closes kept rising to 109 at bars 6 and 7. MACD fell first because the rise was slowing: +2 per bar, then +1, then 0. The line went below zero only at bar 10, the third bar of falling closes.
What the MACD line measures: trend speed in price units#
The MACD line measures how fast price has been moving, smoothed and expressed in price units. Each EMA trails a steady trend by its average age, (n − 1)/2 bars: 5.5 bars for EMA(12) and 12.5 bars for EMA(26). If price rises by d every bar, the fast EMA sits 5.5 × d below price and the slow one 12.5 × d below, so their difference is a constant (12.5 − 5.5) × d = 7 × d. A flat MACD line means a steady trend, a rising line means the trend is speeding up, and a falling line, even above zero, means it is slowing.
Figure 1 tests this on a series built for this lesson (synthetic data): price rises exactly 0.50 USDT per bar to 130 at bar 61, then falls 0.50 per bar.
- During the rise, the MACD line and the signal line both sit at exactly 3.5 and the histogram is zero. Nothing is changing, so there is no signal.
- One bar after the top, the fast EMA reacts more than the slow one, the MACD line dips below the signal line and the histogram turns negative.
- Fifteen bars after the top, the fast EMA finally drops below the slow one and MACD crosses zero. By then price has fallen 7.5 from its top, 5.8%. At bar 101, after 40 bars of decline, MACD is −2.9 and still moving toward −3.5, which is 7 × −0.50.
Reading MACD on a chart#
Read MACD in three layers: its sign (fast EMA above or below the slow one), its direction (trend speeding up or slowing down) and its crossings with the signal line (a change in that direction, smoothed). The histogram shows the gap between the MACD line and its signal: when the bars shrink toward zero, a crossover is getting close. Figure 2 shows invented daily closes (synthetic data) with EMA(12) and EMA(26) on the price and MACD(12, 26, 9) below.
- The rise. MACD crossed above zero on day 43, when the close was 101.92, and stayed positive as price climbed 62.5% to its top of 165.58 on day 92. The MACD line peaked the same day at 11.12.
- The histogram peak (day 88). The histogram reached 1.57 four days before the top: the MACD line was still rising but no longer pulling away from its signal line. Read alone, this would have been an early warning.
- The signal-line cross (day 96). The MACD line crossed below its signal four days after the top. The close was 157.36, already 5.0% below the top.
- The zero cross (day 109). MACD went negative 17 days after the top, at a close of 141.21, 14.7% below the top. The decline continued to 116.12 on day 136, 29.9% below the top, so both signals still came before most of the fall here.
Why MACD signals lag a turn#
Every MACD signal waits for averages of past closes to respond, and each extra layer adds delay. The MACD line has to turn first, which needs the fast EMA (average age 5.5 bars) to react more than the slow one (12.5 bars). A signal-line crossover then needs the MACD line to fall below a 9-bar average of itself, which adds about 4 bars of average age. A zero cross needs the fast EMA to fall all the way below the slow one, which takes longest.
How long each takes depends on the shape of the turn:
- On a sharp, clean turn, the signal-line cross is quick: 1 bar after the top in Figure 1. The zero cross took 15 bars.
- On a noisier turn, the cross comes later: 4 days after the top in Figure 2, and the zero cross 17 days after it.
- On a gradual, rounded top, the MACD line peaks while price is still rising, because the rise is slowing. The MACD line can then be below its signal line before price makes its high, as in the step-by-step table, where it was already below at bar 7 while the close of 109 matched the high. That can look like foresight, but it only says the trend has slowed, which also happens in trends that resume.
Traders who act on crossovers face the same trade-off as with any moving average rule: waiting for confirmation gives worse prices, and acting early gives more false signals. A trade triggered by a daily close can only be filled at a price available after that close, for example the next day's open.
When MACD misleads: a divergence in a strong trend#
A divergence is a disagreement between price and MACD: a bearish divergence is a higher high in price with a lower high in MACD, and a bullish divergence is the reverse at lows. It is often read as a sign that a trend is about to end. What it actually shows is that the trend has slowed, because MACD measures speed. A trend can slow down and keep going. Figure 3 shows invented daily closes (synthetic data) designed for this case: the series rises about 1.6% a day for 22 days, then about 0.6% a day.
- First high (day 65). The close was 149.34 and the MACD line was at its peak, 10.58.
- Signal-line cross (day 69). MACD crossed below its signal at a close of 151.27, as the steep part of the rise ended.
- Second high (day 88). The close was 163.77, 9.7% higher, but MACD was 5.70, 46.1% lower. That is a bearish divergence.
- What followed. Price kept rising to 184.40 on day 118, its highest close: 12.6% above the day 88 high and 21.9% above the close on the day of the signal-line cross. MACD never fell below 4.42 after day 65 and never crossed zero, because the fast EMA stayed above the slow one throughout.
The divergence correctly said that the rise had slowed from about 1.6% to 0.6% a day. It did not say the rise would end. Two more sell crosses, on days 104 and 110, were also followed by higher prices. A trader who reads divergence as a reversal signal needs a separate reason to expect the trend to end, and a plan for when it does not.
Why MACD values are not comparable across assets#
MACD is measured in the chart's price units, so its size depends on the price level, not only on the strength of the trend. Multiply every price by 600 and every MACD value is multiplied by 600, although the chart looks the same. In Figure 2, MACD peaked at 11.12 USDT when EMA(26) was 144.19, a gap of 7.7% of price. The same 11.12 on a pair trading near 60,000 USDT would be a gap of about 0.02%, hardly a trend at all. The same problem applies to one asset over time: a MACD reading from when an asset traded at 100 cannot be compared with one from when it traded at 1,000.
The usual fix is to divide by the slow EMA, which gives the percentage price oscillator. It is explained in Why use a percentage version of MACD? PPO and TRIX.
Which MACD: TA-Lib's warm-up alignment and other variants#
Platforms agree on the formula but not always on where the EMAs start, so early MACD values can differ between them. This lesson starts each EMA from the simple average of its first n inputs: EMA(12) from bars 1 to 12, EMA(26) from bars 1 to 26. TA-Lib, a widely used open-source library, instead places the fast EMA's starting window so that both EMAs start on the same bar: on bar 26, its EMA(12) starts from the average of bars 15 to 26. Both versions produce the first MACD value on bar 26 and the first signal value on bar 34, and the slow EMA is identical in both.
On the closes of Figure 2, the two MACD lines differed by 0.018 USDT on day 26, and the difference shrank by a factor of 11/13 each day, staying under 0.005 from day 34. The difference was small there because the first month moved sideways; its size depends on how prices moved in the first 26 bars. Other software may start each EMA from the first close instead of an average, which also changes the early values. Before comparing MACD values across platforms or using early values in a test, check which starting rule each uses and discard the first few dozen bars.
A related setting is the price source. MACD is normally calculated from closes; a chart set to use another input, such as the average of high and low, shows different values.
Stocks and crypto: what 12, 26 and 9 days cover#
MACD counts bars, not calendar days, so the same settings span different amounts of time. On daily candles of a US stock, 26 bars are 26 trading sessions, about 5.2 weeks, and weekends and exchange holidays are skipped. Each overnight gap between sessions enters MACD as one jump from one close to the next. On a crypto pair, which trades every day, 26 daily candles are 26 calendar days, about 3.7 weeks, and weekend moves are included.
Applied to five-minute or hourly candles, the same 12, 26 and 9 settings describe minutes or hours of trading, and the meaning of a crossover changes with them. MACD has no special settings for different markets: a reader comparing signals across markets or timeframes should compare what the settings cover in time.
Check your understanding: MACD#
Question. On today's close, EMA(12) of a token is 105.40 USDT and EMA(26) is 104.10 USDT. Yesterday's signal line, EMA(9) of MACD, was 1.50.
- What are today's MACD line, signal line and histogram?
- Is the trend up or down, and is it speeding up or slowing down?
- Another asset shows a MACD of 400 with its EMA(26) at 89,600 USDT. Is its trend stronger?
Show the answers
Answer.
- MACD = 105.40 − 104.10 = 1.30. The signal line uses α = 2 ÷ (9 + 1) = 0.2: 1.50 + 0.2 × (1.30 − 1.50) = 1.46. Histogram = 1.30 − 1.46 = −0.16.
- MACD is positive, so the fast EMA is above the slow one: recent prices are higher than older ones, an uptrend on this measure. The MACD line is below its signal line and the histogram is negative, so MACD has been falling: the rise is slowing. That is not a sell signal by itself. Like the divergence in Figure 3, it can happen in a trend that continues.
- The numbers cannot be compared directly, because MACD is in price units. As a percentage of the slow EMA, the token's gap is 1.30 ÷ 104.10 = 1.25% and the other asset's is 400 ÷ 89,600 = 0.45%. On this measure the token's trend is stronger, despite its much smaller MACD. That conversion is the idea behind the percentage price oscillator.
Related lessons#
- Before this lesson: What does a moving average actually measure?
- Next: Why use a percentage version of MACD? PPO and TRIX
- Next: What do TSI and the Awesome Oscillator smooth out?
- See also: Which moving average reacts fastest, and what does speed cost?
- See also: What does RSI measure, and why do "overbought" signals fail?
- See also: What do the McClellan Oscillator and the Arms Index (TRIN) show?
- See also: What is look-ahead bias, and how does it get into a backtest?