The difference between two EMAs, plus a signal line computed as an EMA of that difference. Crosses zero when the EMAs cross, and the histogram (MACD − Signal) flips first when momentum turns. Probably the most-used hybrid trend/momentum indicator in retail trading.
MACD(12, 26, 9) on MES 5m — line, signal, histogram
What it measures
- Trend-following momentum. MACD line above zero = fast EMA above slow EMA = uptrend in progress. Below zero = inverse.
- Momentum acceleration. Histogram (MACD − Signal) increases when momentum strengthens, decreases when it fades.
- Crossover signals. MACD/Signal crossover is the canonical trade trigger; zero-line crosses are slower, higher-conviction trend-shift markers.
Formula
How AlgoLift computes it
MACD Line: EMA(price, fast_period) − EMA(price, slow_period)
Signal Line: EMA(MACD Line, signal_period)
Histogram: MACD Line − Signal Line
Default settings (12, 26, 9) come from Gerald Appel's original 1970s design. The fast EMA reacts to recent prices; the slow EMA reacts to longer-term prices; their difference reflects the convergence/divergence between the two horizons.
The histogram is the most-watched element by professional users — its sign change always precedes the MACD/Signal crossover by one bar.
Inputs in AlgoLift
| Setting | Default | Range | Notes |
|---|---|---|---|
| Fast Period | 12 | 1–500 | Lookback for the fast EMA. |
| Slow Period | 26 | 1–500 | Lookback for the slow EMA. |
| Signal Period | 9 | 1–500 | EMA period for the signal line. |
Recommended settings
- (12, 26, 9) — default: The classic. Works across timeframes from 5m to weekly.
- (5, 13, 5): Faster — for short-timeframe execution. More signals, more noise.
- (19, 39, 9): Slower — for swing setups on daily bars.
The three periods interact — fitting all three independently is a classic overfitting trap. If you must tune, change one parameter at a time.
Outputs in AlgoLift
| Handle | Type | Plotted | Notes |
|---|---|---|---|
| MACD Line | Numeric | Always | The main line. Zero-line crosses indicate EMA crossovers. |
| Signal Line | Numeric | Always | EMA of MACD. The lagging reference for crossover signals. |
| Histogram | Numeric | Always | MACD − Signal. Tracks momentum acceleration. |
| MACD Line Slope | Numeric | On select | Rate of change of MACD line. |
| Signal Line Slope | Numeric | On select | Rate of change of Signal line. |
| Histogram Slope | Numeric | On select | Earliest momentum-shift signal — slope flips before histogram does. |
MACD node — default state with all six outputs
Reading the components together
MACD's three primary outputs work as a sequence of signals at different speeds:
- Histogram slope flips first — earliest momentum warning.
- Histogram sign flips next — MACD line just crossed Signal line.
- MACD/Signal crossover is the formal crossover event (same moment as histogram sign flip — they're algebraically identical).
- MACD line crosses zero is the slowest — confirms the underlying EMAs have actually crossed.
A strategy can trigger off any of these four events. Earlier = more sensitive (more whipsaws); later = more reliable (lower entry quality).
MACD's value is its three time horizons in one panel — histogram slope (earliest), MACD/Signal crossover (middle), zero-line cross (slowest). Pick which horizon matches your strategy's holding period, and ignore the others.
Best in / worst in
Best in trending markets with clear momentum cycles, on instruments with consistent volatility (ES, MES, NQ during RTH), and as a confirmation tool alongside price-level analysis.
Worst in sideways chop, where MACD whipsaws across zero continuously. Also weak on very-short timeframes where the EMA periods produce noise rather than signal.
Three setups
1. Signal-line crossover
The canonical MACD entry.
- Long: MACD Line crosses above Signal Line AND MACD > 0 (already in bullish regime).
- Short: MACD Line crosses below Signal Line AND MACD < 0.
The MACD > 0 filter eliminates countertrend crossovers — the lowest-quality MACD signals.
MACD signal-line crossover with zero-line filter
2. Histogram-led early entry
Trigger one bar before the line/signal crossover by reading the histogram.
- Long: Histogram crosses above 0 AND Histogram Slope > 0 (accelerating) AND price > EMA(50).
- Short: Symmetric.
The slope requirement filters out histogram sign-changes that immediately reverse.
3. Zero-line momentum entries
Use MACD's zero-line cross as a slower, higher-conviction trend-change signal.
- Long: MACD Line crosses above 0 AND price > SMA(200).
- Short: Symmetric with MACD crossing below 0.
Fewer signals than crossovers, but each one means the EMAs themselves have crossed — a real regime shift.
Advanced patterns in AlgoLift
MACD divergence with BarsAgo Modifier. Compare current MACD Line against MACD 10 bars ago, with price comparison alongside. When price makes a new high but MACD doesn't follow, momentum is fading — bearish divergence. Strong contrarian signal in range regimes; combine with KAMA ER < 0.3 to avoid trend-fades.
Histogram-triggered scale-ins. Enter on the standard MACD/Signal crossover for the initial position. Then use a Scaled Entry that fires when the histogram reaches a new high (or low for shorts) — confirms momentum is accelerating, not just briefly turning. Adds size to winners.
MACD as a regime filter for unrelated strategies. Use MACD > 0 / MACD < 0 as a binary regime classifier in front of a price-action strategy (e.g., Fair Value Gap entries). Only allow trades aligned with the MACD regime. A simple, no-tuning regime gate.
Multi-timeframe MACD confirmation. Add a 1h data series alongside your 5m execution. Only allow 5m MACD entries when the 1h MACD is in the same direction. Cross-timeframe momentum agreement dramatically reduces the false-signal rate. See the multi-series Visual Builder pattern.
Multi-timeframe MACD confirmation
Common mistakes
- Treating every crossover as a trade. MACD on a trending instrument produces dozens of crossovers per year; many are countertrend noise. The zero-line filter is essential.
- Using MACD alone in chop. When price oscillates around a single level, MACD whipsaws across zero on every cycle. Pair with a regime filter or pause the strategy during low-volatility windows.
- Optimizing the three periods together. Three interacting parameters — fast track to overfitting. The (12, 26, 9) defaults are sensible across most situations.
- Ignoring the histogram slope. Histogram slope flips before the histogram does. Strategies that only read the histogram value miss the earliest signal in the indicator.