Academy · · 13 min · By Álvaro García
MACD Indicator: What It Is, How to Calculate and Use It
MACD indicator explained: the 12-26-9 formula with a worked example, the 4 signals and when they fail, 10 years of S&P 500 data and MetaTrader's MACD.

In short: the MACD is a momentum indicator that subtracts the 26-period exponential moving average from the 12-period one; from that line you derive a signal line (a 9-period average) and a histogram (the gap between the two). It tells you whether a trend is gaining or losing strength, not where the price is going: over 10 years of S&P 500 data, its crossovers were barely more accurate than any random day.
The MACD indicator (Moving Average Convergence Divergence) measures the distance between two exponential moving averages of the price to show whether a trend's momentum is building or fading. It has three components: the MACD line, the signal line and the histogram.
It was developed by the American analyst Gerald Appel in the late 1970s, according to StockCharts, and today it comes built into every platform (MetaTrader, TradingView, ProRealTime). In this guide you will see how to calculate it by hand with a checked example, the four signals traders actually use, what 10 years of crossovers on the S&P 500 reveal, how the MetaTrader MACD differs, why the same MACD value means different things on two different assets, and the mistakes that cost beginners the most money.
What is the MACD indicator?
The MACD is a trend-following oscillator that subtracts the 26-period exponential moving average (EMA) from the 12-period EMA. A positive reading means recent prices are running above those of the past few weeks and momentum is bullish; a negative reading means momentum is bearish. The further it moves from zero, the stronger the move.
The idea is simple: a fast average reacts to changes sooner than a slow one. When the two pull apart (diverge), the trend is accelerating; when they come together (converge), it is losing steam. The MACD turns that distance into a single line that oscillates around zero, with no upper or lower bound, unlike the RSI, which always moves between 0 and 100.
If you are not yet comfortable with moving averages, start with our guide to simple and exponential moving averages: the MACD is simply a structured way of comparing them.
MACD line, signal line and MACD histogram
1. MACD line
This is EMA(12) − EMA(26). On daily candles, it compares the weighted average price of roughly two and a half weeks of sessions with that of just over a month. It is the indicator's "fast" line.
2. Signal line
This is a 9-period average calculated on the MACD line itself, not on the price: exponential in the classic version and simple in MetaTrader. It smooths the MACD line and acts as the reference for crossovers: when the MACD line cuts through it, short-term momentum has changed direction.
3. MACD histogram
This is the difference between the MACD line and the signal line, plotted as bars. According to StockCharts, it was developed by Thomas Aspray to anticipate signal-line crossovers: the bars shrink before the two lines meet, so the histogram warns you ahead of the crossover. StockCharts calls it "an indicator of an indicator", because it measures how the MACD itself is changing.
How to calculate the MACD step by step
An EMA gives more weight to recent data through a multiplier α = 2 ÷ (n + 1). It is updated each day with this formula: today's EMA = yesterday's EMA + α × (closing price − yesterday's EMA).
- 12-period EMA: α = 2 ÷ 13 = 0.1538
- 26-period EMA: α = 2 ÷ 27 = 0.0741
- 9-period signal: α = 2 ÷ 10 = 0.20
Worked example (illustrative figures)
Imagine a stock with these values yesterday: EMA(12) = €105.00, EMA(26) = €103.70 and signal line = 1.20. Today it closes at €107.60.
- Today's EMA(12): 105.00 + 0.1538 × (107.60 − 105.00) = 105.00 + 0.40 = €105.40.
- Today's EMA(26): 103.70 + 0.0741 × (107.60 − 103.70) = 103.70 + 0.29 = €103.99.
- MACD line: 105.40 − 103.99 = 1.41.
- Signal: 1.20 + 0.20 × (1.41 − 1.20) = 1.20 + 0.042 = 1.24.
- Histogram: 1.41 − 1.24 = 0.17.
How to read it: the MACD is positive (the fast average is above the slow one) and it is also above its signal line, with the histogram in positive territory. Bullish momentum is present and, in this session, it has strengthened. Note that the fast EMA rose by €0.40 and the slow one by only €0.29: that difference in speed is exactly what the indicator measures.
One point almost no guide mentions: an EMA needs history to settle. With the classic settings, the first signal value can be calculated from the 34th candle (26 + 9 − 1), but it still depends on how the average was seeded. In the 26-period EMA, the weight of the starting value does not fall below 1% until around 60 candles of calculation, so you should have at least 100–150 candles of history.
How to read the MACD: the 4 main signals
1. Signal-line crossover
This is the best-known signal. When the MACD line crosses above the signal line, short-term momentum turns up; when it crosses below, it turns down. It is also the signal that produces the most false alarms, because in a market without a trend the two lines cross again and again.
2. Zero-line crossover
When the MACD line moves from negative to positive, the 12-period EMA has overtaken the 26-period EMA: it is the same as a bullish crossover of those two averages on the price chart. It comes later than the signal-line crossover, which is why many textbooks use it as a filter: only take bullish signal-line crossovers when the MACD is above zero. Further down you will see that, on the S&P 500 at least, that filter did not improve results.
3. Divergences
A bearish divergence occurs when the price makes a higher high but the MACD makes a lower high: the rally continues with less force. A bullish divergence is the opposite, with lower lows in price and higher lows in the MACD. It is a warning, not an entry signal: a divergence can last for weeks while the price keeps moving in the same direction.
4. Histogram turns
When the histogram bars start to shrink, momentum is slowing even if the trend continues. It is the earliest of the four warnings and, for that very reason, the one that most often comes to nothing. It works better as an alert to watch the chart than as a trigger to buy or sell.
This table summarises how they behave, as a rough guide (speed follows from how each signal is calculated; for the reliability of the signal-line crossover, see the data in the next section):
| Signal | What it shows | Speed | What to watch for |
|---|---|---|---|
| Histogram shrinks | Momentum is slowing | First | Many warnings that lead nowhere |
| Signal-line crossover | Short-term momentum turns | Fast | Frequent crossovers in sideways markets |
| Zero-line crossover | The 12 EMA moves above or below the 26 EMA | Slow | Arrives late after fast moves |
| Divergence | The trend is losing strength | Variable | Can last weeks without resolving |
What 10 years of data show: MACD crossovers on the S&P 500
To test how much the most popular signal is really worth, we at Audited Traders calculated the daily 12-26-9 MACD of the S&P 500 using closing prices published by Yahoo Finance. We took every crossover between 24 October 2016 and 23 October 2026 (the most recent 10 years with at least 20 subsequent sessions) and checked where the index stood 20 sessions later, roughly one month.
| Situation | Cases | Index higher 20 sessions later | Average change |
|---|---|---|---|
| Any day in the period (baseline) | 2,514 | 69.0% | +1.10% |
| Bullish signal-line crossover | 111 | 70.3% | +1.20% |
| Bullish crossover with MACD above zero | 73 | 68.5% | +0.76% |
| Bullish crossover with MACD below zero | 38 | 73.7% | +2.04% |
The conclusion is uncomfortable for anyone who trades crossovers alone. Buying on any random day was right 69.0% of the time; buying after a bullish crossover, 70.3%. With 111 cases, the 95% confidence interval for that percentage runs from roughly 62% to 79%, so the difference is indistinguishable from chance. Sell signals tell the same story: after the 111 bearish crossovers, the index was lower 20 sessions later in only 33.3% of cases, against 31.0% for any given day.
The most striking result contradicts the textbook rule: bullish crossovers with the MACD below zero were right more often (73.7%) than those above it (68.5%). The likely explanation is the market itself: in an index that rose over the decade, buying after declines tended to pay off as prices recovered. They also show more dispersion, because there are only 38 cases: with a 95% interval of about ±14 points, that edge is not statistically distinguishable from the baseline. And in a prolonged bear market, the result could be the reverse.
Method: daily closes of the index (^GSPC) downloaded from Yahoo Finance on 20 November 2026; a hit means the index was higher (or lower, for bearish crossovers) 20 sessions after the crossover; EMAs seeded with the simple average of the first periods; 9-period EMA signal, the convention used by TradingView and StockCharts; excluding dividends and trading costs. This is historical data for a single index and a single horizon, not a guarantee of anything. It shows why the MACD is useful for reading momentum, not as a trading system on its own.
The MACD after a sharp sell-off: the March 2020 case
The Covid crash is the best recent example of how the indicator behaves in a violent decline. Using the same S&P 500 data:
- 19 February 2020: the index closes at a record 3,386.15.
- 21 February: bearish signal-line crossover at 3,337.75. Twenty sessions later, the index stood at 2,304.92, 30.9% lower.
- 23 March: closing low of 2,237.40.
- 26 March: first bullish signal-line crossover, at 2,630.07, with the MACD still at −190, far below zero. Twenty sessions later, the index stood at 2,836.74 (+7.9%).
- 16 April: the MACD climbs back above zero at 2,799.55. Twenty sessions later, 2,852.50 (+1.9%).
Two lessons. First, the February bearish crossover came late relative to the peak, but in time to avoid almost the entire fall. Second, the bullish crossover below zero, the one textbooks tell you to ignore, was the earliest signal of the rebound, while waiting for the zero-line crossover cost around 170 points of upside. The same period also shows the cost of false signals: the bearish crossovers of 13 May and 11 June were followed by gains of 6.5% and 6.1% over the next 20 sessions. In 2020 the recovery was V-shaped; in a longer decline, that same early crossover may be just a bounce before another leg down. So before acting on any crossover, work out where your exit would be with the stop loss and take profit calculator.
MACD in MetaTrader 4 and 5: why it doesn't match TradingView
If you trade on MT4 or MT5, the MACD you see is not exactly the one described in most guides. According to the official MetaTrader 5 help, the MACD line is the same, EMA(12) − EMA(26), but the signal line is a 9-period simple moving average, SMA(MACD, 9), not an exponential one.
- The bars are the MACD line. On the chart, MetaTrader draws the MACD as bars and the signal as a dotted line on top. There is no MACD − signal histogram by default.
- Crossovers don't always coincide. In our S&P 500 data, of 222 crossovers with the exponential signal, 119 occurred on the same day with the simple signal. Most of the rest came one or two sessions earlier or later.
- The settings have different names. In the indicator window you will see "Fast EMA", "Slow EMA" and "MACD SMA": 12, 26 and 9 by default.
If you want the classic histogram in MetaTrader, you need a custom indicator that plots MACD − signal (free ones are available in the MQL5 code base, usually with names such as "MACD with histogram"). What matters is knowing what you are looking at: if you read the MT4 bars as if they were the histogram, you will misread every signal.
Why you can't compare the MACD of two assets
This is the most confusing point. The MACD is expressed in the same units as the price: in the earlier example, 1.41 is in euros. A MACD of 1.41 is meaningful momentum for a €107 stock, but it would be negligible for an index trading in the thousands of points; in March 2020, the S&P 500's MACD reached −190. Even on the same asset, a MACD of 2 when the stock was worth €50 is not the same as a MACD of 2 when it is worth €500.
What this means in practice:
- There are no fixed overbought or oversold levels. A "very high" MACD is only high relative to its own recent history.
- To compare assets or long periods, use the percentage version, the percentage price oscillator (PPO): (EMA 12 − EMA 26) ÷ EMA 26 × 100. In the example, 1.41 ÷ 103.99 × 100 = 1.36%, a figure you can compare with another stock's.
Best MACD settings: 12, 26, 9 and alternatives
The values 12, 26 and 9 are the standard on almost every platform, as noted by StockCharts and TradingView's help pages. You can change them, but understand the trade-off:
- Shorter periods (StockCharts gives 5-35-5 as an example): more sensitivity and earlier signals, but also more signals that go nowhere.
- Longer periods or a MACD on the weekly chart: fewer, later signals, useful for seeing the underlying trend.
- Timeframe: the same 12-26-9 on 5-minute candles measures momentum over an hour; on daily candles, over several weeks.
Tweaking the settings until they "work" on past data is a common trap: what you are optimising is the noise of that particular period, and it rarely repeats.
Common MACD mistakes
- Trading every crossover. In sideways markets, crossovers come one after another, and each one brings its own commission and small loss. The S&P 500 data show that, on their own, they offer barely any edge.
- Treating a divergence as a sell signal. The trend can run much further than seems reasonable.
- Comparing values across assets. Without converting to the PPO, the MACD figure is not comparable.
- Mistaking MetaTrader's bars for the histogram. In MT4 and MT5 the bars are the MACD line.
- Using it without risk management. No signal replaces a stop and a properly calculated position size. You can work it out with our position size calculator.
MACD pros and cons
| Advantages | Limitations |
|---|---|
| Combines trend and momentum in a single panel | Lags: it is based on past averages |
| Easy to calculate and available on every platform | Many signals that go nowhere in sideways markets |
| The histogram anticipates crossovers | No fixed overbought or oversold levels |
| Works on stocks, indices, forex, commodities and crypto | Values can't be compared across assets (use the PPO) |
Remember that trading leveraged products such as CFDs or futures carries a high level of risk. The analysis by national regulators cited by the European Securities and Markets Authority (ESMA) in 2018 found that between 74% and 89% of retail CFD accounts lost money; today every EU broker must publish its own percentage in its risk warning. A technical indicator helps you structure your decisions, but it does not reduce the risk of the product.
Frequently asked questions
What does MACD stand for?
Moving Average Convergence Divergence. It measures how far two exponential moving averages of the price move towards or away from each other, the 12-period and 26-period averages in the standard version.
What is the MACD histogram?
The bars that show the difference between the MACD line and its signal line. When the bars grow, momentum is accelerating; when they shrink, it is slowing, and they usually do so before the two lines cross.
What are the best MACD settings?
There is no single best setting for every case. 12-26-9 is the standard and the one used by almost every trader; shorter periods give earlier signals but more noise, and longer ones do the opposite. Optimising the values on past data tends to create a false sense of precision.
Is MACD better than RSI?
They measure different things. The MACD tracks the trend and its momentum; the RSI is an oscillator bounded between 0 and 100 that shows whether a move is overextended. They complement each other: the MACD shows the direction of momentum and the RSI whether the move is stretched.
How do you set up the MACD in MT4?
In MetaTrader 4 it is under Insert → Indicators → Oscillators → MACD. The default values are Fast EMA 12, Slow EMA 26 and MACD SMA 9. Remember that the bars are the MACD line and the signal is a simple average, so crossovers don't always match those on TradingView.
Who invented the MACD?
Gerald Appel developed it in the late 1970s, according to StockCharts and Britannica Money. The histogram used today was later developed by Thomas Aspray.