Complete MACD Indicator Guide
Real Uses of Golden/Death Crosses
The MACD (Moving Average Convergence Divergence) was invented by Gerald Appel in 1979 and is the most classic trend-following indicator in technical analysis. Almost everyone has heard "buy the golden cross, sell the death cross," but looking at crosses alone gives roughly a 50% win rate — about the same as a coin flip. This post explains why and how to improve on it.
1. What Is MACD? What Do the Three Lines Do?
MACD has three components:
1. MACD line = EMA(12) − EMA(26)
The difference between the two moving averages. When the short EMA is above the long EMA, MACD > 0; otherwise < 0. It quickly reflects the relationship between short-term and long-term momentum.
2. Signal line = EMA(MACD, 9)
A 9-period EMA of the MACD line, which reacts a bit slower. Treat it as a "smoothed reference" for the MACD line.
3. Histogram = MACD − Signal
The difference between the two lines, shown as a histogram. A positive histogram (green bars) = MACD above Signal = bullish momentum; a negative one (red bars) = bearish momentum.
2. Beginner Use: Golden / Death Cross
This is the textbook version:
- Golden cross: MACD line crosses above the Signal line → buy
- Death cross: MACD line crosses below the Signal line → sell
Pine implementation (pure cross, for teaching):
//@version=5
strategy("MACD Pure Cross (Teaching)", overlay=true)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
if (ta.crossover(macdLine, signalLine))
strategy.entry("Long", strategy.long)
if (ta.crossunder(macdLine, signalLine))
strategy.entry("Short", strategy.short)3. Intermediate Use: MACD + Zero-Line Filter
A golden cross occurring above the zero line (MACD > 0) means something different from one occurring below the zero line (MACD < 0):
- Golden cross above zero: a pullback buy in an uptrend, higher win rate
- Golden cross below zero: a weak bounce, often a false breakout
- Bearish crosses are symmetric (more reliable below the zero line)
//@version=5
strategy("MACD + Zero Line Filter", overlay=true)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
// Only accept long cross above zero + short cross below zero
longSignal = ta.crossover(macdLine, signalLine) and macdLine > 0
shortSignal = ta.crossunder(macdLine, signalLine) and macdLine < 0
if (longSignal)
strategy.entry("Long", strategy.long)
if (shortSignal)
strategy.entry("Short", strategy.short)4. Advanced Use: MACD Histogram Contraction
The histogram isn't just positive vs. negative — its absolute size reflects momentum strength. When red bars get consecutively shorter (negative values shrinking), bearish momentum is fading and a bounce may be near. This signals 1–2 bars earlier than a cross.
//@version=5
indicator("Histogram Squeeze Detection", overlay=false)
[_, _, hist] = ta.macd(close, 12, 26, 9)
// 3 consecutive shrinking red bars → short momentum exhaustion
weakening_down = hist < 0 and hist > hist[1] and hist[1] > hist[2] and hist[2] > hist[3]
// 3 consecutive shrinking green bars → long momentum exhaustion
weakening_up = hist > 0 and hist < hist[1] and hist[1] < hist[2] and hist[2] < hist[3]
bgcolor(weakening_down ? color.new(color.green, 80) : na, title="Long Warning")
bgcolor(weakening_up ? color.new(color.red, 80) : na, title="Short Warning")5. Pro Use: MACD Divergence
Like RSI, MACD also has divergence signals:
- Price makes a new high, MACD does not → bearish divergence
- Price makes a new low, MACD does not → bullish divergence
MACD divergence works on the same principle as RSI divergence, but MACD divergence usually shows up earlier (because MACD reacts more sensitively to short-term momentum). You can watch both and use them as cross-confirmation.
ta.pivothigh and ta.pivotlow for finding local highs and lows. Comparing the direction of price pivots against MACD pivots is enough to code a divergence detector. TradingView also has plenty of public "MACD Divergence" scripts you can reference.6. Can You Change MACD Parameters?
The defaults (12, 26, 9) come from Wilder's daily-bar work back in the day. For different markets and timeframes, you can tweak them:
| Scenario | Suggested params | Rationale |
|---|---|---|
| Standard (traditional) | (12, 26, 9) | General-purpose |
| More sensitive (short-term) | (5, 13, 5) | Catches short-term turns; more noise |
| More stable (medium/long-term) | (19, 39, 9) | Filters noise but signals are slow |
| High-vol crypto perps | (12, 26, 9) or (8, 17, 9) | Standard still works; the shorter set handles fast moves better |
7. Common Mistakes
Using MACD in a chop market
MACD is a trend-following indicator, and chop produces a string of fake crosses. Use ADX or a volatility indicator to gauge market state first, and only use MACD when you're in a trending regime.
Using MACD with no stop loss
MACD gives you an entry signal, not exit protection. Pair it with an ATR stop or a fixed-percentage stop — non-negotiable.
Mismatched timeframes
A 1-hour MACD golden cross while the daily is in a death cross → you're entering counter-trend, with a low win rate. Establish the higher-timeframe direction first, then use the lower timeframe to time your entry.
Get started
Wire your strategy to a TradingView webhook and auto-execute on Binance / OKX / Bybit and 4 more.
Start free trial8. Advanced: MACD + RSI Double-Confirmation Strategy
A common live combo: MACD gives the entry, RSI filters trend direction.
//@version=5
strategy("MACD + RSI Double Confirmation", overlay=true)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
rsi = ta.rsi(close, 14)
// Long: MACD golden cross + MACD > 0 + RSI > 50
longSignal = ta.crossover(macdLine, signalLine) and macdLine > 0 and rsi > 50
// Short: MACD death cross + MACD < 0 + RSI < 50
shortSignal = ta.crossunder(macdLine, signalLine) and macdLine < 0 and rsi < 50
if (longSignal)
strategy.entry("Long", strategy.long)
if (shortSignal)
strategy.entry("Short", strategy.short)