MACD

The gap between a fast and a slow exponential average, with a signal line, to track momentum.

MACD: line = EMA(x, fast) − EMA(x, slow); signal = EMA(line, signal); histogram = line − signal. EMAs are seeded with the SMA of their first inputs; needs fast < slow. Line ready at slow candles, signal and histogram at slow + signal − 1. Mirror: signed for all three (a mirrored price swaps which average is above).

Settings

SettingDefaultRangeWhat it does
fast121 to 500Fast EMA length.
slow262 to 500Slow EMA length.
signal91 to 500Signal EMA length.

What it gives

OutputWhat it is
MACD lineMACD line, price difference.
Signal lineSignal line.
HistogramHistogram = line − signal.

What it reads

It reads open, high, low, close, hl2, hlc3, ohlc4, hlcc4, close by default.

Warm-up

With its default settings, MACD needs 140 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses MACD with its default settings