Skip to content

Technical indicators

MACD Histogram

MACD minus its signal line, on its own, as columns.

The same histogram as the third value of MACD with a signal line. It is above zero while MACD is above its signal line.

Traders watch it cross zero, which is MACD crossing its signal, and its columns shrinking, which shows momentum fading before the cross.

histogram = MACD(fast, slow) − EMA(MACD, signalEMAPeriods)

Call: macdHistogram(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 number.

Warm-up: with macdHistogram(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.

MACD Histogram drawn by its own code on example prices

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.

let previous;
function onIntervalClose() {
const value = macdHistogram(12, 26, 9);
if (OPEN_POSITIONS_COUNT === 0 && previous !== undefined && previous < 0 && value > 0) {
openPosition("BUY", { quantity: 10000, stopLossPips: 25, takeProfitPips: 50 });
}
previous = value;
}