如何在仍在贸易中预防其他信号? (Pine脚本)

发布于 2025-01-25 09:47:50 字数 277 浏览 2 评论 0原文

我正在尝试在Pine脚本4中编码一个指标,但是我不会多次贸易信号,而另一个理论交易仍然会活跃。稍后,我将添加一个“关闭位置”警报,但现在我只关注第一个信号,直到出现下一个绿色的Heikin Ashi蜡烛为止。

I am trying to code an indicator in Pine Script 4, but I do not wan´t multiple trade signals while another theoretical trade would still be active. I will add a "close position" alert later on but for now I only wan´t the first signal until the next green heikin ashi candle appears.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

披肩女神 2025-02-01 09:47:50

使用var查看您是否已经在交易中。

这应该给你一个想法:

var is_long = false

is_green = (close > open)
is_red = not is_green

long_cond = not is_long and barstate.isconfirmed and is_green  // Enter only if we are not already long
short_cond = is_long and barstate.isconfirmed and is_red  // Enter only if we are already long

is_long := long_cond ? true : short_cond ? false : is_long  // Update the flag

// Reset the flag when you exit

Use a var to see if you are already in a trade.

This should give you an idea:

var is_long = false

is_green = (close > open)
is_red = not is_green

long_cond = not is_long and barstate.isconfirmed and is_green  // Enter only if we are not already long
short_cond = is_long and barstate.isconfirmed and is_red  // Enter only if we are already long

is_long := long_cond ? true : short_cond ? false : is_long  // Update the flag

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