Reputation: 2981
I want to write this ThinkOrSwim statement in Pinescript:
MACD.Diff()
I tried this:
MACD = ta.macd(close, 12, 6, 9)
ta.sma(MACD, 9)
But I get the below error:
Syntax error: Variables of array type are not supported!
What's the correct way to get the difference between MACD and its moving average in Pinescript?
Upvotes: 0
Views: 1098
Reputation: 21121
ta.macd
returns a tuple of three MACD series: MACD line, signal line and histogram line.
I believe what you are looking for is the histogram line.
//@version=5
indicator("My Script")
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
plot(histLine, color=color.red, style=plot.style_histogram)
Upvotes: 2