MACD (Moving Average Convergence Divergence)
The Moving Average Convergence Divergence indicator plots the difference between a 12-period EMA and a 26-period EMA (the MACD line) alongside a 9-period EMA of that difference (the signal line). The gap between the two lines is shown as a histogram. Together they identify trend direction, momentum strength, and shifts in either.
How MACD is constructed
MACD has three components and one historical author. Gerald Appel introduced it in the late 1970s, and the default parameters he picked — 12, 26, 9 — have stuck for half a century almost unchanged.
- MACD line —
12 EMA(close) − 26 EMA(close). Positive when fast EMA is above slow (uptrend bias); negative when below (downtrend bias). - Signal line —
9 EMA(MACD line). Smoother version of the MACD line, used as a crossover trigger. - Histogram —
MACD line − Signal line. Visualises whether momentum is accelerating (growing bars) or decelerating (shrinking bars).
The defaults are designed for daily charts, but they work reasonably well across timeframes. Faster pairs (5, 13, 5) are sometimes used for intraday; slower pairs (19, 39, 9) for weekly trend confirmation.
The four MACD signals
MACD generates four distinct signals — each with different reliability and best-use cases.
1. Signal-line crossover
The most-quoted signal. The MACD line crosses above the signal line → bullish; below → bearish. Late by design (you're using a 9-period smoothed version of an already-lagging moving average), so it filters noise but misses early entry.
2. Zero-line crossover
The MACD line itself crosses above zero (12 EMA crosses above 26 EMA) → confirmed uptrend; below → confirmed downtrend. Slower than the signal-line cross but a stronger trend confirmation.
3. Histogram divergence
Price makes a new high, but the MACD histogram makes a *lower* high. Momentum is fading even though price isn't yet — often a leading indicator of a reversal. The reverse (lower price low + higher histogram low) is a bullish divergence. Divergence is the most-traded MACD signal among discretionary traders and the easiest to misread — only act on it after a confirming price action.
4. Histogram acceleration
When the histogram bars are growing in the direction of the trend, momentum is accelerating. Shrinking bars while price still moves favourably warns the trend is running out of steam. Useful as a position-management tool rather than an entry signal.
Why the 12/26/9 defaults
The three numbers approximate two and four trading weeks plus 1.5 weeks of smoothing. There's nothing magical about them — they're a reasonable compromise on daily charts of major US equities, which is where Appel was working. On other instruments and timeframes the optimal values shift, and any robust strategy should test alternatives via walk-forward analysis before committing.
That said, three reasons to *keep* the defaults:
- Reflexivity — millions of traders watch 12/26/9 charts. Crossovers there move price simply because so many people react to them.
- Out-of-sample stability — defaults that have survived 50 years of public trading are unlikely to be curve-fit. Custom values that beat them by 5% in backtest usually fail in live trading.
- Comparability — every screener, every TradingView script, every MetaTrader template assumes 12/26/9. Custom values become a maintenance burden.
MACD in Pine Script
//@version=5
strategy("MACD Crossover", overlay=true)
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
// Long on bullish signal-line crossover above the zero line (extra filter)
if ta.crossover(macdLine, signalLine) and macdLine > 0
strategy.entry("Long", strategy.long)
// Exit on bearish crossover
if ta.crossunder(macdLine, signalLine)
strategy.close("Long")The macdLine > 0 filter is the difference between a textbook MACD strategy (mediocre) and a deployable one. Trading only crossovers in the direction of the underlying trend is the most reliable MACD edge — it doubles win rate at the cost of a few entries.
MACD vs RSI
MACD and RSI get confused because both are "momentum oscillators," but they answer different questions.
- MACD is *unbounded* and tells you about the relationship between fast and slow trends. It's a trend-following tool with momentum colour.
- RSI is *bounded 0-100* and tells you how stretched price is from its recent average. It's a mean-reversion tool with overbought/oversold thresholds.
You can't directly compare a MACD reading of 1.2 across instruments — it depends on price scale. RSI is comparable: 70 means the same thing on EUR/USD as on Bitcoin. Many trend-following systems use both: MACD for direction, RSI for entry timing.
Common MACD mistakes
- Trading every crossover. Without a trend filter, MACD whipsaws in ranging markets. Add a 200 EMA filter or an ATR volatility check.
- Reading divergence too early. Divergence can persist for weeks before reversing. Always wait for confirming price action — a swing high break, a candle close, anything that proves the move is real.
- Optimising the parameters. Default 12/26/9 is rarely beaten in walk-forward. Time spent re-tuning would be better spent building entry filters.
- Ignoring the histogram. The histogram leads the signal-line crossover by 1-3 bars. Watching the bars shrink in real time gives you a head start on the eventual cross.
MACD in PineForge strategies
PineForge ships several strategies that use MACD as a primary or filter signal. See EMA Crossover for a related implementation, Triple EMA for a multi-MA trend confirmation, and Momentum V7 for a MACD + ADX + volume hybrid.
Frequently Asked Questions
What does MACD stand for?+
MACD stands for Moving Average Convergence Divergence. It refers to how two exponential moving averages — typically the 12-period and 26-period EMA — converge (move closer) and diverge (move apart) over time, with the gap plotted as the indicator's primary line.
What are the best MACD settings?+
The default 12, 26, 9 settings work well across most markets and timeframes and are the values nearly every other trader watches — which gives them reflexive significance. Faster settings like 5, 13, 5 suit intraday scalping; slower settings like 19, 39, 9 suit weekly trend confirmation. Only deviate from defaults after walk-forward analysis confirms the change is robust.
How do I trade a MACD crossover?+
Wait for the MACD line to cross above the signal line for a long entry, or below for a short. The most reliable filter is to only take crossovers when the MACD line is above zero (uptrend) for longs, or below zero (downtrend) for shorts. This single rule typically doubles win rate vs. trading every crossover blind.
What is MACD divergence?+
MACD divergence happens when price makes a new high but the MACD histogram makes a lower high — momentum is fading even though price hasn't yet rolled over. Bullish divergence is the reverse: lower price low, higher histogram low. Divergence is a leading reversal signal but unreliable on its own. Always wait for confirming price action like a swing-high break or a strong candle close before acting.
Is MACD better than RSI?+
Neither is better — they measure different things and complement each other. MACD captures trend direction and momentum acceleration with no fixed range. RSI tells you how overbought or oversold price is on a 0-100 scale. Many systematic strategies use MACD for trend direction and RSI for entry timing within that trend.
Does MACD work on cryptocurrency?+
Yes, with adjustments. Crypto is more volatile and trends harder than forex or equities, so the default 12/26/9 generates more whipsaws on lower timeframes. Either move to a higher timeframe (4H or daily) or pair MACD with a volatility filter that suppresses signals when ATR is contracting. Bitcoin and Ethereum on the daily chart respond well to standard MACD trend logic.
Strategies that use MACD (Moving Average Convergence Divergence)
Related Terms
EMA (Exponential Moving Average)
The exponential moving average weights recent price data more heavily than older bars, making it faster to react than a simple moving average.
RSI (Relative Strength Index)
The RSI oscillates between 0 and 100, measuring the velocity of recent gains vs losses to identify overbought and oversold conditions.
Crossover
A crossover happens when one series crosses above another — used as the entry signal in moving-average and oscillator-based strategies.
Walk-Forward Analysis
Walk-forward analysis tests a strategy by optimising on one window and testing on the next — repeated rolling forward through history. The most honest backtest you can run.
Stop Reading. Start Trading.
PineForge backtests every concept on this site against real market data.
Try It Free