![](/img/trans.png)
[英]Either repainting (because calc_on_order_fills=true) or my trailing stop loss in the strategy.exit is not working, Pine, Tradingview
[英]Only enter a trade once per bar when calc_on_order_fills=true, Pine Script, Tradingview
我想添加以下条件之一,以避免我的策略在已经输入交易的柱上进行交易。 例如:在 1 小时图表上,最后一笔交易是在 12 点钟输入的,并由同一柱中的追踪止损 function 关闭。 现在下一个交易条目应该最早出现在下一个柱的开始( 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 strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index
它有效,但在一个柱中有多个条目。 而这正是我试图避免的。
我添加了这个条件:
and (strategy.closedtrades == 0 or strategy.closedtrades.entry_bar_index(strategy.closedtrades-1) < bar_index)
关键部分是
strategy.closedtrades == 0
否则,你永远不会进入交易
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.