仅在趋势发生变化时触发绘图形状或警报
buysignal = (close > vwap) and (close > ema24)
sellsignal = (close < vwap) and (close < ema24)
// draw some shapes on the chart if conditions are met
plotshape(buysignal, title = 'long', style=shape.triangleup, size=size.normal, text='up')
plotshape(sellsignal, title = 'short', style =shape.triangledown, size=size.normal, text='down')
// create alert conditions!
alertcondition(buysignal, title="Buy-Signal", message="bull")
alertcondition(sellsignal, title="Sell-Signal", message="bear")
我编写了一些类似上面的代码来识别趋势。您能否帮我弄清楚,如何仅在趋势从牛市变为熊市或相反时触发图形形状或警报,而不是在每根蜡烛收盘时触发?谢谢。
buysignal = (close > vwap) and (close > ema24)
sellsignal = (close < vwap) and (close < ema24)
// draw some shapes on the chart if conditions are met
plotshape(buysignal, title = 'long', style=shape.triangleup, size=size.normal, text='up')
plotshape(sellsignal, title = 'short', style =shape.triangledown, size=size.normal, text='down')
// create alert conditions!
alertcondition(buysignal, title="Buy-Signal", message="bull")
alertcondition(sellsignal, title="Sell-Signal", message="bear")
I have written some code like the above to identify trend. Can you please help me figure out, how do I trigger a plot shape or alert only when the trend changes from bull to bear or vice versa and not for every candle close? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将之前的状态与当前的状态进行比较。然后你在你的职能中。
Compare the previous state with the current state. Then you that in your functions.