talib.macd

Moving average convergence/divergence for source, from three lengths: fastlen, slowlen and siglen. One call covers the whole study, including the signal line that siglen sizes.

talib.macd(series float source, series int fastlen, series int slowlen, series int siglen) → [series float, series float, series float]
ParameterTypeRequiredDescription
sourceseries floatyesThe series the study is built on.
fastlenseries intyesThe faster of the two averaging lengths.
slowlenseries intyesThe slower of the two averaging lengths.
siglenseries intyesLength used for the signal line.

Returns [series float, series float, series float] — Three series float values as a tuple, in the order line, signal, histogram.

indicator("MACD")
[line, signal, histogram] = talib.macd(close, 12, 26, 9)
plot(line, title = "Line")
plot(signal, title = "Signal")
plot(histogram, title = "Histogram")

See also talib.alma · talib.atr · talib.barssince

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade