Trend / momentum indicator
MACD (Moving Average Convergence Divergence)
A trend-following momentum indicator built from two moving averages.
What is MACD (Moving Average Convergence Divergence)?
MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator that shows the relationship between two exponential moving averages of price. It consists of the MACD line, a signal line, and a histogram of the difference between them.
How it works
The MACD line is the difference between a fast EMA (classically 12) and a slow EMA (26). A signal line (a 9-period EMA of the MACD line) is plotted on top. When the MACD line crosses above the signal line, momentum is turning up; when it crosses below, down. The histogram visualises the gap, expanding as momentum accelerates and contracting as it fades.
How traders use it
- ▸Signal-line crossovers: enter on MACD crossing its signal line.
- ▸Zero-line crosses: MACD above/below zero confirms trend direction.
- ▸Histogram momentum: shrinking bars warn that a move is losing steam.
- ▸Divergence: price/MACD disagreement flags potential reversals.
Build MACD (Moving Average Convergence Divergence) without code in Algovex
Algovex provides MACD as a node with its line, signal and histogram outputs exposed. Wire a crossover trigger into your entry logic, add a trend filter, backtest, and export to four languages. The visual canvas makes multi-condition MACD systems readable without code.
Works well with
Common mistakes
- ✕Trading every signal-line crossover, including the whipsaws that happen in ranges. Filter by the zero line or a trend.
- ✕Reading the histogram as direction rather than momentum, it shows acceleration, not bias.
- ✕Expecting MACD to call tops and bottoms; it lags by design.
- ✕Optimising 12/26/9 to perfection on one dataset (overfitting).
Key parameters
| Parameter | What it does |
|---|---|
| fastLength | Fast EMA period (default 12). |
| slowLength | Slow EMA period (default 26). |
| signalLength | Signal-line EMA period (default 9). |
| source | Price input, usually close. |
Frequently asked questions
What are the best MACD settings?
The default 12, 26, 9 is the most widely used. Faster settings react sooner but whipsaw more. Always backtest on your instrument and timeframe before committing.
Is MACD a leading or lagging indicator?
MACD is primarily a lagging, trend-following indicator because it's built from moving averages, but its histogram and divergence can give earlier momentum warnings.