Docs

ta.macd

Compare a fast and a slow average to read momentum shifts and crossovers.

itm
ta.macd(source, fast, slow, signal)

Moving Average Convergence/Divergence: [ema(fast) - ema(slow), ema of that over signal, their difference].

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
fastConstantnumber121 to 10000Window in observed bars.
slowConstantnumber261 to 10000Window in observed bars.
signalConstantnumber91 to 10000Window in observed bars.

Outputs

NameType
macdnumber
signalnumber
histnumber

The outputs come back in this order: [macd, signal, hist] = ta.macd(…).

Warm-up and missing values

Warm-up
slow + signal - 1 bars. Names in the warm-up are this operator’s parameters.
Missing values
The first output is na until the slow exponential average warms up. The signal and histogram are na until the signal average warms up on top of that.

Example

itm
[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
itm
[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
plot(hist, "Histogram")
plot(macdLine, "Line")