What is the point of using this
lastdataclose = np.array([self.data.get(size = 100)])
but not simply this
lastdataclose = self.data.get(size = 100) # baktrader approach
I can know that cause I place an order with exectype=bt.Order.Market
market order doesn't have 100% execution guarantee. For example, it will be a gap up next bar, and
open price will not allow you to buy the size you wanted cause it will be no funds.
It seems to me that you encountered the issue discussed here several times even in 2017. Try to search the forum for resampling with live data. As I remember
bt uses one approach when do resampling, and
ib uses another approach for already formed bars. Honestly I didn't follow that discussions, and don't know if this was resolved or not.
@vladisld may help if he has time.
But when you use bracket order, it's assumed that you notify broker about these 2 or 3 orders at the same time.
There are number of notifications sent. Some of them such as
accepted goes at the same time. Notifications like
completed can't go at the same time by
bracket order idea. Your
main order can be executed only on the 2nd bar and (logically) you will know this only at the end of the 2nd bar. How do you plan to know at the end of the first bar that it is executed?
It would be great to have something like process_orders_on_close=True, because i have my time for one run increased 2x with this solution.
Sure, but time machine is not invented yet.
Indicators depend on the prices and on the data feed length in case of recursive indicators. Indicators mentioned above are mostly recursive. There are no logs and script provided, therefore hard to say what is going on.
To continue debugging please provide the following:
next()during the LIVE session
next()made during historical backtest session
@ab_trader just to clarify - not indicator period, but total number of bars available?
@mv do you use the same number of bars to calculate indicator values with historical data and with live data?
Please prove with the logs of the execution date and price.
I don't see any issues here. Bracket order is issued on the 1st bar, broker notified, then main order is executed on the 2nd bar, broker notified, now stop order is active starting from the 3rd bar.
To get quicker notofications move to lower timeframe.
First guess would be that the script you try to run has
backtrader.py name. Rename it. If it doesn't fix the error, than you have some issue swith the installation. Feel free to google how to fix
ModuleNotFoundError: error. Correctly installed and used
bt doesn't return this error.