仅在CalC_On_Order_fills = true,Pine脚本,TradingView时只输入一次每栏交易
我想添加以下条件之一,以避免我的策略进入已经进入交易的酒吧的交易。 例如:最后一次交易是在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我补充了以下条件:
关键部分是
,您永远不会从事交易
I added this condition:
the key part is
otherwise, you never get into a trade