仅在CalC_On_Order_fills = true,Pine脚本,TradingView时只输入一次每栏交易

发布于 2025-02-13 23:39:55 字数 1115 浏览 1 评论 0原文

我想添加以下条件之一,以避免我的策略进入已经进入交易的酒吧的交易。 例如:最后一次交易是在1小时的图表中以12 O'Clock进行的,并被尾随的停止功能关闭,进入了同一酒吧。现在,下一个交易的下一个条目应最早在下一个bar的开头(calc_on_order_fills设置为true),

strategy.closedtrades.entry_bar_index(strategy.closedtrades) != bar_index

strategy.closedtrades.entry_time(strategy.closedtrades) != time

但它不起作用。 任何人都可以帮助解决这个问题吗?并向我解释为什么它不起作用?

编辑:

//Submit entry orders
if (LongCondition and time>timestamp(2022, 07, 01, 06, 00) and strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)
    strategy.entry(id = "Long", direction = strategy.long, alert_message = "Place Long Order", comment = "Long Entry")


if (ShortCondition and time>timestamp(2022, 07, 01, 06, 00) and strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)
    strategy.entry(id = "Short", direction = strategy.short, alert_message = "Place Short Order", comment = "Short Entry")

没有此:and Strateg.closedtrades.entry_bar_index(stragity.closedtrades-1)&lt; BAR_INDEX它有效,但在一个栏中有几个条目。这就是我试图避免的。

I want to add one of the following conditions to avoid my strategy entering a trade on a bar where already a trade was entered.
Eg: Last trade was entered at 12 o´clock on an 1 hour chart and was closed by the trailing stop function into this same bar. Now the next entry for a trade should be earliest in the beginning of the next bar (calc_on_order_fills is set to true)

strategy.closedtrades.entry_bar_index(strategy.closedtrades) != bar_index

strategy.closedtrades.entry_time(strategy.closedtrades) != time

But it doesn´t work.
Can anyone please help to solve this issue? And explain to me why it doesn´t work?

EDIT:

//Submit entry orders
if (LongCondition and time>timestamp(2022, 07, 01, 06, 00) and strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)
    strategy.entry(id = "Long", direction = strategy.long, alert_message = "Place Long Order", comment = "Long Entry")


if (ShortCondition and time>timestamp(2022, 07, 01, 06, 00) and strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)
    strategy.entry(id = "Short", direction = strategy.short, alert_message = "Place Short Order", comment = "Short Entry")

Without this: and strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index it works, but with several entrys in one bar. And that´s what I try to avoid.

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

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

发布评论

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

评论(1

晨曦÷微暖 2025-02-20 23:39:55

我补充了以下条件:

and (strategy.closedtrades == 0 or strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)

关键部分是

strategy.closedtrades == 0 

,您永远不会从事交易

I added this condition:

and (strategy.closedtrades == 0 or strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)

the key part is

strategy.closedtrades == 0 

otherwise, you never get into a trade

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