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
| Setting | Default | Range | What it does |
|---|---|---|---|
| fast | 12 | 1 to 500 | Fast EMA length. |
| slow | 26 | 2 to 500 | Slow EMA length. |
| signal | 9 | 1 to 500 | Signal EMA length. |
What it gives
| Output | What it is |
|---|---|
| MACD line | MACD line, price difference. |
| Signal line | Signal line. |
| Histogram | Histogram = 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