仅在趋势发生变化时触发绘图形状或警报

发布于 2025-01-15 12:18:13 字数 611 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2025-01-22 12:18:13

将之前的状态与当前的状态进行比较。然后你在你的职能中。

is_new_buy_signal = not buysignal[1] and buysignal

Compare the previous state with the current state. Then you that in your functions.

is_new_buy_signal = not buysignal[1] and buysignal
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文