← Indicators

MACD in Practice: Trend, Momentum and Divergence

23 Oct 2026 · 2 min read

BullsEdges algo trading guide: The MACD combines trend and momentum in one indicator. Learn what its lines and histogram show, the common signals, and how to use it in an algorithm.

The Moving Average Convergence Divergence (MACD) indicator, created by Gerald Appel, measures the relationship between two moving averages. It is popular because it shows both direction and momentum in one place.

BullsEdges algo trading application: Define whether MACD contributes direction, momentum or timing, and measure whether it improves results after costs.

The components

  • MACD line: the 12-period EMA minus the 26-period EMA. Positive when the short-term average is above the long-term one.
  • Signal line: a 9-period EMA of the MACD line.
  • Histogram: the MACD line minus the signal line. It grows when momentum is accelerating and shrinks when it slows.

Common signals

1. Zero-line position

MACD above zero means the 12 EMA is above the 26 EMA - a short-term uptrend. Below zero, a downtrend. This works as a simple trend filter.

2. Signal-line crossovers

MACD crossing above the signal line is a bullish momentum signal; crossing below is bearish. These crossovers are frequent and give many false signals in ranges. They work better when taken only in the direction of a bigger trend.

3. Histogram turns

When the histogram stops growing and starts shrinking, momentum is fading - often before the lines cross. Some traders use this for earlier exits.

4. Divergence

Price makes a new high but MACD makes a lower high: momentum is weakening. Divergence is a warning, not a timing tool; strong trends can show several divergences before reversing.

Using MACD in an algorithm

A practical structure:

  1. Trend: only buy when price is above the 200 EMA.
  2. Setup: wait for MACD to dip below its signal line (a pullback in momentum).
  3. Trigger: buy when MACD crosses back above the signal line while still in the uptrend.
  4. Exit: a fixed risk-reward target, or when MACD crosses down again.

Test whether each part adds value. Often the trend filter does most of the work, and the MACD trigger mainly improves timing.

Things to watch

  • MACD values are in price units, so a MACD level on gold is not comparable with one on EURUSD. Use crossovers and zero-line signals, not absolute levels, if the strategy runs on several symbols.
  • The default 12/26/9 settings are a convention, not an optimum. Check that results are stable across nearby settings.
  • Like all moving-average tools, MACD lags. It confirms trends rather than predicting them.

BullsEdges takeaway for algo trading

MACD is a useful momentum and trend tool, especially as a filter and for timing pullback entries. On its own, crossover trading in sideways markets is costly. Combine it with a trend filter and test it on your symbol and timeframe.

Trading forex and gold carries a high level of risk and may not be suitable for every investor. Past performance and backtests do not guarantee future results. This article is education, not financial advice.

Start your 1 month free trial

Full access to the Finoways Forex & XAUUSD algo, setup support included.