Reputation: 7
I've tried to calculate the area between the signal line and the MACD line and to plot a cross on the chart each time there is a cross between these two lines and/or to plot a cross each time the area between the signal line and the MACD line is near zero and the signal line is below the MACD line.
I've found a script on Trading View that does what I want when it comes a cross between the lines mentioned above and I was trying to create the script to calculate the area between the lines and plot the "x" whenever the area is going to be zero under one circumstance (the signal line must be below the MACD line).
When I try to run the script it prompt this error "Syntax error at input 'plot'".
plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, linewidth=2, plot.style_line)
plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, linewidth=4, plot.style_histogram)
plot(sd and ta.cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", plot.style_circles, linewidth=4, color=macd_color)
hline(0, '0 Line', linestyle=solid, linewidth=2, color=white)
The error occur at 'plot.style_line/histograms/circles' and I didn't know how to solve it, if there's someone that can help me it would be great!
Upvotes: 0
Views: 574
Reputation: 21342
Once you start naming argument names in a function call, you should do it for rest of the arguments.
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, linewidth=2, plot.style_line)
In the above code, you start naming the arguments with the name
argument. You do it for the rest except the style
. So, you should add style=
before your style variable.
Also, your hline()
seems to be < v3, so you need to update that too.
plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, linewidth=2, style=plot.style_line)
plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, linewidth=4, style=plot.style_histogram)
plot(sd and ta.cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=plot.style_circles, linewidth=4, color=macd_color)
hline(0, '0 Line', linestyle=hline.style_solid, linewidth=2, color=color.white)
Upvotes: 0