How come this line of code is note working? I'm able to plot without the If statement, but I want it to plot only when both condition are met.
Thank you for your time!
showMA = input.string(group="GENERAL SETTINGS", title="Moving Averages:", defval="EMA", options=["EMA", "VWAP", "Both", "None"])
show_threeEma = input.bool(group="EMA - Exponensial Moving Average", title="233-EMA", defval=true, inline="ema")
threeEma = 233
ema_space = 4 // Dash Spacing
threeEmaLength = ta.ema(close, threeEma) //233-EMA
If (showMA == "EMA" and show_threeEma or showMA == "Both" and show_threeEma == "Show")
plot(bar_index % ema_space != 0 ? threeEmaLength : na, style=plot.style_linebr, linewidth=2, color=color.new(color.silver, 25), editable=false, title="233-EMA")
You cannot use plot()
functions in local scope.
However, you can use your condition as part of your series
argument in your plot()
call. Just like you didi with bar_index % ema_space != 0
.
can_show = (showMA == "EMA" and show_threeEma or showMA == "Both" and show_threeEma == "Show")
plot((can_show and (bar_index % ema_space != 0)) ? threeEmaLength : na, style=plot.style_linebr, linewidth=2, color=color.new(color.silver, 25), editable=false, title="233-EMA")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.