MACD
The gap between a fast and a slow moving average, in pips.
What it measures
Section titled “What it measures”MACD is the fast EMA minus the slow EMA. It is positive when the recent price is above the longer average and grows as the trend speeds up. With signalEMAPeriods, it adds an EMA of MACD as a signal line and the difference between the two as a histogram. Cloud9Trader gives MACD in pips, so it reads the same on every currency pair; most platforms give it in price.
How traders read it
Section titled “How traders read it”Traders read MACD crossing its signal line as a turn in momentum and MACD crossing zero as the fast average crossing the slow one. A histogram shrinking towards zero shows the move losing pace.
Formula
Section titled “Formula”MACD = (EMA(fast) − EMA(slow)) / pip sizesignal = EMA(MACD, signalEMAPeriods)histogram = MACD − signalSettings and output
Section titled “Settings and output”Call: macd(fastEMAPeriods, slowEMAPeriods, signalEMAPeriods)
| Setting | Chart default |
|---|---|
fastEMAPeriods: Fast EMA Periods |
12 |
slowEMAPeriods: Slow EMA Periods |
26 |
signalEMAPeriods: Signal EMA Periods |
9 |
What you get: a list of 3, in this order: 1. a number (“MACD”); 2. a number (“MACD Signal”); 3. a number (“MACD Histogram”).
Warm-up: with macd(12, 26, 9), it asks for 26 bars of history and a run-up of 61, and its first value came on bar 35 of the example data.
The prices are made up, hourly, and the same on every page, so the chart shows how the indicator behaves, not how a market behaved.
In an algorithm
Section titled “In an algorithm”let wasAbove = false;
function onIntervalClose() { const lines = macd(12, 26, 9); const above = lines[0] > lines[1]; if (OPEN_POSITIONS_COUNT === 0 && above && !wasAbove) { openPosition("BUY", { quantity: 10000, stopLossPips: 25, takeProfitPips: 50 }); } wasAbove = above;}Without signalEMAPeriods, macd(12, 26) gives a single number. On an instrument without pips in the usual sense, such as a crypto pair, the value is scaled by that instrument’s pip size.