如何检测是否触发straution.exit()?

发布于 2025-01-17 18:03:58 字数 328 浏览 2 评论 0原文

如何检测strategy.exit()是否已被触发?

下面的代码适用于除入场蜡烛之外的不同蜡烛上存在的交易:

detect_exit  = (strategy.position_size[1] > 0 and strategy.position_size == 0) or (strategy.position_size[1] < 0 and strategy.position_size == 0) 

上面的代码行不会捕获同一入场蜡烛上发生的交易。

您知道如何捕获在入场蜡烛的同一蜡烛上发生的退出吗?

How can I detect if strategy.exit() has been triggered or not?

The code below works fine for trades that exist on a different candle other than the entry candle:

detect_exit  = (strategy.position_size[1] > 0 and strategy.position_size == 0) or (strategy.position_size[1] < 0 and strategy.position_size == 0) 

The line of code above doesn't catch exists that occur on the same entry candle.

Do you have any idea how to catch exits that happened on the same candle of the entry candle?

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

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

发布评论

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

评论(1

你在看孤独的风景 2025-01-24 18:03:58

您可以使用建造的封闭交易来参考交易价格和时间。在这里,我们检查位置尺寸和相对于出口酒吧

detect_exit = strategy.position_size == 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index

欢呼的当前酒吧,并度过美好的一天

You can reference trade prices and times using the closed trades built ins. Here we check position size and the current bar relative to the exit bar

detect_exit = strategy.position_size == 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index

Cheers and have a great day

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