Skip to content
Algo Trade Analytics Docs

ta.macd() - Pine Script Function

MACD (moving average convergence/divergence). It is supposed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock’s price.

ta.macd(source, fastlen, slowlen, siglen) → [series float, series float, series float]
NameTypeDescription
sourceseries int/floatSeries of values to process.

Tuple of three MACD series: MACD line, signal line and histogram line.

  • na values in the source series are ignored; the function calculates on the length quantity of non-na values.
//@version=6
indicator("MACD")[_, signalLine, _] = ta.macd(close, 12, 26, 9)
plot(signalLine, color=color.orange)