提问人:jonahmano 提问时间:4/7/2023 最后编辑:jonahmano 更新时间:4/7/2023 访问量:21
仅在触发买入变量后触发卖出变量的条件
Condition to trigger sell variable only after buy variable is triggered
问:
我有两个变量,分别称为买入和卖出。我希望在触发或绘制买入变量后,只触发或绘制一次卖出变量。下次卖出变量只有在下一个买入变量收到警报或绘制时才能发出警报或绘图。
请问你能帮我处理代码吗?
//@version=5
indicator("My Script", overlay=true)
var strongbuytriggered = false
var bbrsellplotted = false
strongbuy = (close > ta.sma(close, 10)) and (ta.slope(close, 5) > 0)
bbrsell = ta.crossover(ta.sma(close, 20), ta.ema(close, 20))
alertcondition(strongbuy, title="A Strong Buy Signal", message="Strong buy")
alertcondition(condition=bbrsell, title="Sell Signal", message="Sell")
if strongbuy
strongbuytriggered := true
bbrsellplotted := false
if bbrsell and strongbuytriggered and not bbrsellplotted
// Plot sell condition with yellow triangle
plot_shape(triangledown, location=location.abovebar, color=color.rgb(241, 124, 222), size=size.normal, title="Sell")
bbrsellplotted := true
if not strongbuy
strongbuytriggered := false
bbrsellplotted := false
答: 暂无答案
评论