MACD
Difference of two EMAs with a signal line and histogram.
indicator("MACD", precision=4)
src = input.source(close, "Source")
fastLen = input.int(12, "Fast length", minval=1)
slowLen = input.int(26, "Slow length", minval=1)
sigLen = input.int(9, "Signal length", minval=1)
[macdLine, signalLine, hist] = ta.macd(src, fastLen, slowLen, sigLen)
rising = hist > hist[1]
histColor = hist >= 0 ? (rising ? color.new(color.green, 30) : color.new(color.green, 65)) : (rising ? color.new(color.red, 65) : color.new(color.red, 30))
plot(hist, "Histogram", color=histColor, style=plot.style_columns)
plot(macdLine, "MACD", linewidth=2)
plot(signalLine, "Signal")
hline(0, "Zero", color=color.new(color.gray, 50))