您如何实施定时限额订单?

发布于 2025-01-20 09:05:52 字数 263 浏览 0 评论 0原文

我想到了这个管道:

1. condition to enter a trade becomes TRUE
2. opens a limit order at a pre-calculated price
3. wait 3 bar closes (or 3 hours, for example. variable.)
4. if the order has not filled, cancel the order

特别是,如何实施步骤 3-4?

I have this pipeline in mind:

1. condition to enter a trade becomes TRUE
2. opens a limit order at a pre-calculated price
3. wait 3 bar closes (or 3 hours, for example. variable.)
4. if the order has not filled, cancel the order

Particularly, how can steps 3-4 be implemented?

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

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

发布评论

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

评论(1

故人爱我别走 2025-01-27 09:05:52

您可以使用内置策略。Cancel()函数取消待处理限制顺序,检查长期3个bars的条件是否在3个bars之前并取消订单,以防万一填充 - 不会受到影响。

下面的脚本将触发条件长时间使用鼠标单击图表,其中给定的限制值以限制顺序,并取消订单,以防下一个3个bars中执行:

//@version=5
strategy("My strategy", overlay=true)

itime = input.time(0, confirm = true)

limitValue = math.min(close[1], low[2])

longCondition = time == itime

if longCondition
    strategy.entry("MyLong", strategy.long, limit = limitValue)
    label.new(bar_index, limitValue, 'Entry Order')

strategy.cancel("MyLong", nz(longCondition[3]))

You can cancel the pending limit order using the built-in strategy.cancel() function, check if the condition for long was true 3 bars ago and cancel the order, in case it was filled - it will be not affected.

The script below will trigger a condition to go long using a mouse click on the chart, with a given limitValue for limit order and cancel the order in case it will not be executed during next 3 bars:

//@version=5
strategy("My strategy", overlay=true)

itime = input.time(0, confirm = true)

limitValue = math.min(close[1], low[2])

longCondition = time == itime

if longCondition
    strategy.entry("MyLong", strategy.long, limit = limitValue)
    label.new(bar_index, limitValue, 'Entry Order')

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