What MACD is made of
MACD line (DIF) = 12-period EMA − 26-period EMA; the signal line (DEA) is the 9-period EMA of the MACD line; histogram = MACD line − signal line (some software multiplies it by 2). At its core it’s a smoothed difference between moving averages, which makes it a trend and momentum indicator.
Three ways to write it as quant rules
- Crossover: go long when the MACD line crosses above the signal line, and close when it crosses below. Lots of signals, and lots of noise.
- Zero-line filter: only accept bullish crossovers when the MACD line is above zero, which filters out bounce signals inside a downtrend.
- Histogram momentum: enter when the histogram turns from negative to positive, or grows for N bars in a row.
Divergence (price makes a new high while MACD doesn’t) is popular in discretionary trading, but it’s hard to write as a strict rule, and backtests can easily end up relying on subjective judgment. Beginners shouldn’t start with it.
One-sentence prompt
On BTC/USDT 4-hour candles, use MACD(12,26,9): only when the MACD line (DIF) is above 0, go long when the MACD line crosses above the signal line (DEA); close the position when the MACD line crosses below the signal line. Stop loss of 4% per trade. Compare the backtest results with and without the zero-line filter.
This article only explains how tools are used and how strategies work. It is not investment advice. Backtest and paper trading performance does not represent future returns. Digital assets and leveraged trading carry extremely high risk; only use money you can afford to lose.