Functions
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.
Syntax
talib.macd(series float source, series int fastlen, series int slowlen, series int siglen) → [series float, series float, series float]
Arguments
source required series float The series the study is built on. fastlen required series int The faster of the two averaging lengths. slowlen required series int The slower of the two averaging lengths. siglen required series int Length used for the signal line. Return Type
[series float, series float, series float] Example
indicator("MACD (TA-Lib)", overlay=false)
shortLength = input(12, "Short EMA")
longLength = input(26, "Long EMA")
signalSmoothing = input(9, "Signal Smoothing")
source = input(close, "Source")
[macdLine, signalLine, hist] = talib.macd(source, shortLength, longLength, signalSmoothing)
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.red, title="Signal Line")
histColor = hist >= 0 ? color.green : color.red
plot(hist, color=histColor, style=plotStyle.histogram, title="Histogram")