how to execute on the close price of the next bar
-
Hello,I come across a problem that I want my order executed on the close price of next bar instead of the open price.Since I use minute-based data,"order.Close" cannot deal with my problem.It is not executed by next minute.I also try to use coc,but it executed on the close of this bar,it is not what I want.
I hope anyone can give me an opinion,thanks a lot!
-
newbie here.
self.buy(price=self.dataclose[1]) may help
-
@flix thanks,I will have a try,hope it works.
-
@flix It doesn't work,the order is still executed on the open price of next bar
-
@ellery said in how to execute on the close price of the next bar:
Hello,I come across a problem that I want my order executed on the close price of next bar instead of the open price.Since I use minute-based data,"order.Close" cannot deal with my problem.It is not executed by next minute.I also try to use coc,but it executed on the close of this bar,it is not what I want.
I hope anyone can give me an opinion,thanks a lot!
The reason why using this method is that I want to backtest on bid_ask data. As I buy on ask price and sell on bid price, I have to trade on two different prices instead of the open price.Then I set bid as open and ask as close, with selling on the next open and buying on the next close.But how could I to make it in practice?