MACD measures the gap between a fast and a slow exponential moving average of the close. Its crossovers and divergences describe changes in trend momentum after they happen; they do not forecast the next move.
What MACD measures
MACD, short for moving average convergence divergence, is a trend-following momentum indicator developed by Gerald Appel in the 1970s. It subtracts a slower exponential moving average (EMA) of the close from a faster one. When the fast average pulls away above the slow one, MACD rises; when the two converge, MACD moves back toward zero; when the fast average drops below the slow one, MACD turns negative.
| Property | MACD |
|---|---|
| Input | Closing prices |
| Standard settings | 12, 26 and 9 periods |
| Components | MACD line, signal line and histogram |
| Scale | Unbounded, in the stock’s price units |
| Midline | Zero, where the two EMAs are equal |
| First values | MACD line after 26 closes; signal line after 34 with the seeding used below |
The three numbers in MACD(12, 26, 9) are the fast EMA period, the slow EMA period and the period of the signal line, an EMA of MACD itself. They are the common default on daily charts, but nothing in the formula requires them, and other settings change every value.
How MACD is calculated
MACD uses three exponential moving averages: two of the close and one of MACD itself. Each EMA moves a fixed fraction of the way from its previous value toward the newest input.
k = 2 ÷ (n + 1)
EMA today = EMA yesterday + k × (input today − EMA yesterday)
MACD line = EMA(12) of the close − EMA(26) of the close
signal line = EMA(9) of the MACD line
histogram = MACD line − signal linen- The EMA period: 12, 26 or 9.
k- The smoothing factor: 0.1538 for 12, 0.0741 for 26 and 0.2 for 9.
An EMA needs a starting value. A common convention, used in the worked example, seeds each EMA with the simple average of its first n inputs: EMA(12) starts at session 12, EMA(26) at session 26 and the signal line at the ninth MACD value, session 34. Other software starts from the first close or from a longer history. Early values then differ between platforms, but the gap shrinks every session, because each new EMA value keeps only part of the old one.
MACD is a difference of two prices, so for a US stock it is in dollars. Its formula divides by nothing, so it has no zero-denominator case; each line simply starts once its averages have their first values.
A worked MACD example
The example uses 50 hypothetical daily closes: a slow decline into session 35 followed by a recovery. All closes are listed so that every average can be recomputed.
| Sessions | Closes ($) |
|---|---|
| 1–10 | 60.00, 60.20, 60.05, 60.30, 60.20, 60.35, 60.15, 60.25, 60.30, 60.15 |
| 11–20 | 60.25, 60.05, 60.20, 59.95, 59.85, 59.90, 59.60, 59.45, 59.55, 59.30 |
| 21–30 | 59.10, 59.15, 58.85, 58.60, 58.70, 58.35, 58.20, 57.90, 58.05, 57.65 |
| 31–40 | 57.30, 57.40, 56.95, 56.65, 56.45, 56.80, 57.20, 57.10, 57.60, 58.05 |
| 41–50 | 58.35, 58.20, 58.75, 59.15, 59.50, 59.45, 59.95, 60.40, 60.70, 61.10 |
EMA(12) starts at session 12 as the average of the first 12 closes, 60.1875. EMA(26) starts at session 26 as the average of the first 26 closes, 59.7231, so the first MACD value is 59.1055 − 59.7231 = -0.6176. The signal line starts at session 34 as the average of the nine MACD values from sessions 26 to 34, -0.7341.
| Session | Close ($) | EMA(12) | EMA(26) | MACD line | Signal line | Histogram |
|---|---|---|---|---|---|---|
| 26 | 58.35 | 59.1055 | 59.7231 | -0.6176 | ||
| 27 | 58.20 | 58.9662 | 59.6103 | -0.6441 | ||
| 28 | 57.90 | 58.8021 | 59.4836 | -0.6814 | ||
| 29 | 58.05 | 58.6864 | 59.3774 | -0.6909 | ||
| 30 | 57.65 | 58.5270 | 59.2494 | -0.7224 | ||
| 31 | 57.30 | 58.3382 | 59.1050 | -0.7668 | ||
| 32 | 57.40 | 58.1939 | 58.9787 | -0.7849 | ||
| 33 | 56.95 | 58.0025 | 58.8285 | -0.8259 | ||
| 34 | 56.65 | 57.7944 | 58.6671 | -0.8727 | -0.7341 | -0.1386 |
| 35 | 56.45 | 57.5876 | 58.5029 | -0.9153 | -0.7703 | -0.1449 |
| 36 | 56.80 | 57.4664 | 58.3767 | -0.9103 | -0.7983 | -0.1120 |
| 37 | 57.20 | 57.4254 | 58.2896 | -0.8641 | -0.8115 | -0.0526 |
| 38 | 57.10 | 57.3754 | 58.2014 | -0.8261 | -0.8144 | -0.0117 |
| 39 | 57.60 | 57.4099 | 58.1569 | -0.7470 | -0.8009 | 0.0539 |
| 40 | 58.05 | 57.5084 | 58.1490 | -0.6406 | -0.7688 | 0.1283 |
| 41 | 58.35 | 57.6379 | 58.1639 | -0.5260 | -0.7203 | 0.1943 |
| 42 | 58.20 | 57.7244 | 58.1665 | -0.4422 | -0.6647 | 0.2225 |
| 43 | 58.75 | 57.8821 | 58.2098 | -0.3276 | -0.5972 | 0.2696 |
| 44 | 59.15 | 58.0772 | 58.2794 | -0.2022 | -0.5182 | 0.3160 |
| 45 | 59.50 | 58.2961 | 58.3698 | -0.0737 | -0.4293 | 0.3556 |
| 46 | 59.45 | 58.4736 | 58.4498 | 0.0238 | -0.3387 | 0.3625 |
| 47 | 59.95 | 58.7008 | 58.5610 | 0.1398 | -0.2430 | 0.3828 |
| 48 | 60.40 | 58.9622 | 58.6972 | 0.2650 | -0.1414 | 0.4064 |
| 49 | 60.70 | 59.2295 | 58.8455 | 0.3840 | -0.0363 | 0.4203 |
| 50 | 61.10 | 59.5173 | 59.0125 | 0.5048 | 0.0719 | 0.4329 |
Read the histogram from session 34. It is most negative at session 35, the lowest close in the series, then shrinks for 3 sessions before turning positive at session 39: the MACD line has crossed above its signal line. The MACD line itself stays below zero until session 46, when EMA(12) moves back above EMA(26), and the signal line follows at session 50.
Values are rounded to four decimals for display; each step uses the unrounded figures.
How to read MACD on a stock chart
MACD is drawn in a pane below price: the MACD line, the signal line and the histogram around a zero line. Read it in layers, from the slowest information to the fastest.
- Zero line. Above zero, the 12-session EMA is above the 26-session EMA; below zero, it is beneath. This is the broad direction of the shorter-term trend.
- Slope of the MACD line. A rising line means the fast EMA is gaining on the slow one, whether MACD is above or below zero.
- MACD against its signal line. The histogram shows this gap, and it changes sign at every signal-line crossover.
- Swings against price. Compare MACD peaks and troughs with price peaks and troughs to find divergence.
- Scale. The values are in dollars, so compare the size of swings within one chart, not across stocks.
In TradeClever, open Stock Charts and add the MACD pane. The fast, slow and signal periods are configurable, with 12, 26 and 9 as defaults. For the basics of candles, ranges and volume, see reading a stock chart.
Signal-line and zero-line crossovers explained
MACD has two kinds of crossover. They answer different questions and arrive at different times.
| Crossover | What crosses | What it describes | Timing |
|---|---|---|---|
| Signal-line crossover | The MACD line crosses its 9-session EMA | MACD has turned relative to its own recent path | Earlier and more frequent |
| Zero-line crossover | The MACD line crosses zero | EMA(12) has crossed EMA(26): a moving-average crossover | Later and less frequent |
In the worked example, the signal-line crossover comes at session 39, 4 sessions after the lowest close and while MACD is still negative. It records that the decline’s momentum has faded relative to its recent average, not that the decline has ended. The zero-line crossover at session 46 is the moment EMA(12) moves above EMA(26). It comes later because MACD has to climb all the way back from its low; by then the close was $3.00 above the lowest close.
In sideways markets the two EMAs stay close together, and the lines can cross back and forth repeatedly. A crossover describes two averages; it is not an instruction.
MACD histogram interpretation
The histogram plots MACD minus its signal line. It is zero when the two lines cross, positive when MACD is above the signal line and negative when it is below.
Because the signal line is an average of MACD, the histogram measures how far MACD has moved away from its own recent path. That makes it the fastest of the three components: it can turn while MACD and the signal line are still moving the old way. In the worked example the histogram is at its most negative at session 35 and starts shrinking at session 36, 3 sessions before the crossover.
| Aspect | Signal line | Histogram |
|---|---|---|
| What it is | A 9-session EMA of the MACD line | The MACD line minus the signal line |
| How it is drawn | A second line over MACD | Bars above and below zero |
| Main reading | Crossovers with the MACD line | Bars growing or shrinking |
| Speed | Smoothed, slower | The fastest of the three components |
Shrinking bars mean MACD is converging with its signal line. They do not mean the trend is reversing: the bars can shrink and then grow again without any crossover.
MACD divergence, and how it differs from a crossover
A MACD divergence compares two price swings with the MACD values at the same sessions. A bullish divergence is a lower low in price with a higher MACD low; a bearish divergence is a higher high in price with a lower MACD high.
The illustration on this page shows a bullish divergence on hypothetical data. Price closes at 51.00 at low A and lower, at 50.40, at low B, but MACD reads -2.11 at A and -1.23 at B. The second decline was smaller relative to its moving averages, which is what the divergence records. The first signal-line crossover in the illustration comes between the two lows and is followed by the lower low at B, a reminder that crossovers can come early.
Because MACD is in price units, the size of a divergence depends on the stock’s price and volatility. Compare swings on the same chart, and decide in advance how far apart two swings must be before you compare them.
| Aspect | Crossover | Divergence |
|---|---|---|
| What is compared | Two lines at one session | Two swings in price and in MACD |
| When it is known | At the session it happens | Only after the second swing is complete |
| What it describes | A change in the relationship between averages | Momentum that does not confirm the price swing |
| Main weakness | Frequent crosses in sideways markets | Can persist through several swings |
Divergence describes momentum. Price can keep trending while MACD diverges, sometimes for a long time.
MACD, PPO and comparing stocks
The percentage price oscillator, or PPO, divides the same EMA gap by the slower EMA and multiplies by 100. Expressing the gap as a percentage of price makes readings comparable across stocks with different prices.
PPO = (EMA(fast) − EMA(slow)) ÷ EMA(slow) × 100A MACD of 1.50 is a gap of about 7.50% of price for a $20 stock and about 0.50% for a $300 stock. PPO puts both on the same footing. Its sign always matches MACD’s, because the slow EMA of a positive price is positive, so the division is always defined.
CleverScan offers PPOLine(50, 200, 9), the PPO line built from the 50- and 200-session EMAs of the close. It is a much slower, long-term relative of MACD(12, 26, 9), not the same indicator. A positive value means the 50-session EMA is above the 200-session EMA, so the two rules below express the same condition.
securityType = "Stock" and PPOLine(50, 200, 9) > 0securityType = "Stock" and ema50 > ema200Limitations of MACD
MACD summarizes moving averages, so it inherits their delay and adds the choice of three periods.
- It lags. Every component is an average of past closes, and the zero-line crossover is a moving-average crossover.
- It has no fixed range. There is no built-in overbought or oversold level, and raw values cannot be compared across stocks; PPO addresses the second point.
- Settings and seeding change the numbers. Different periods, or a different starting value for each EMA, give different early readings.
- Sideways markets produce repeated crossovers that quickly reverse.
- Divergence can persist through several swings.
- It sees closes only. Gaps and intraday ranges affect MACD only through the closes they leave behind.
Continue with
- Trend stock screenerStock lists built on trend conditions.
- Rate of change indicatorMomentum as a percentage change.
- Compare technical indicatorsHow common indicators differ.
Sources
- Gerald Appel, Technical Analysis: Power Tools for Active Investors (FT Press, 2005)
Read our data and methodology notes for calculation context. This guide explains research tools and observations. It does not recommend a trade or investment.