Functions
talib.macd()
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.
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 Series of values to process. fastlen required series int Fast Length parameter. slowlen required series int Slow Length parameter. siglen required series int Signal Length parameter. 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")