Limit order execution on high price on the next bar
-
Hi
I create order as buy_brackets and on the next bar the high price is higher than my limit price of order but it doesn't execute.2018-10-01T13:15:00, Open: 0.00003940. High: 0.00003965. Low: 0.00003918. Close: 0.00003920 2018-10-01T13:15:00, Buy. Price: 0.00003920. Limit: 0.00003936. Stop: 0.00003904 2018-10-01T13:20:00, Open: 0.00003933. High: 0.00003941. Low: 0.00003915. Close: 0.00003923 2018-10-01T13:25:00, Open: 0.00003925. High: 0.00003927. Low: 0.00003910. Close: 0.00003911 2018-10-01T13:30:00, Open: 0.00003910. High: 0.00003921. Low: 0.00003908. Close: 0.00003913 2018-10-01T13:35:00, OPERATION PROFIT, GROSS -0.00000016, NET -0.00000016 2018-10-01T13:35:00, Open: 0.00003911. High: 0.00003911. Low: 0.00003900. Close: 0.00003907
Where have I mistake ?
-
@alexander-lifanov seems the mistake is in your code.
-
@ab_trader there is the code
current = self.datas[0] limitprice = (1. + 2 * .005) * current.close[0] stopprice = (1. - .005) * current.close[0] self.log(f'\tBuy. Price: {current.close[0]:.8f}. Limit: {limitprice:.8f}. Stop: {stopprice:.8f}') self.buy_bracket( data=self.data, price=current.close[0], limitprice=limitprice, stopprice=stopprice )
-
@alexander-lifanov said in Limit order execution on high price on the next bar:
Where have I mistake ?
In your understanding about when orders execute (in backtrader and in real-life). Please read: Docs - Order Management and Execution
@alexander-lifanov said in Limit order execution on high price on the next bar:
2018-10-01T13:15:00, Open: 0.00003940. High: 0.00003965. Low: 0.00003918. Close: 0.00003920 2018-10-01T13:15:00, Buy. Price: 0.00003920. Limit: 0.00003936. Stop: 0.00003904
You create an order at
13:15
, which can first be executed with the next bar
@alexander-lifanov said in Limit order execution on high price on the next bar:2018-10-01T13:20:00, Open: 0.00003933. High: 0.00003941. Low: 0.00003915. Close: 0.00003923
The next set of prices ...
@alexander-lifanov said in Limit order execution on high price on the next bar:
2018-10-01T13:25:00, Open: 0.00003925. High: 0.00003927. Low: 0.00003910. Close: 0.00003911
Cannot match your
Limit
sell order because the price for it is0.00003936
which is higher than the highJust follow the logic and understand when and why your order executes.