簡體   English   中英

我對 Pine Script v5 中的“簡單”IF 語句有疑問

[英]I have an Issue with "simple" a IF statemente in Pine Script v5

這行代碼怎么能正常工作? 我可以在沒有 If 語句的情況下使用 plot ,但我希望它只有在滿足兩個條件時才能使用 plot 。

感謝您的時間!

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")

您不能在本地 scope 中使用plot()函數。

但是,您可以在plot()調用中將您的條件用作series參數的一部分。 就像你用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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM