@rajanprabu Can I understand the mechanism as: the SMA indicator can be put in init section of the ibtest.py example because the build-in SMA indicator implemented the "next" method. When live data fits in, Cerebro calls the next() method of the SMA indicator to update the indicator value. Is it correct?
Yes thanks!
I had completely forgotten the market hours.
It working with the correct start/end session.
df = bt.feeds.PandasData(dataname=data,
timeframe=bt.TimeFrame.Minutes,
sessionstart=datetime.time(16,0),
sessionend=datetime.time(22,0),
compression=60,
openinterest=-1)
@bmex-test said in Trade max amount when flipping from short to long or vice versa:
self.dataopen[1]
This code shouldn't run.
Check out this article and this page.
If you are trying to get 100% of your cash invested, this is very challenging since the markets move after an order is issued. Your orders are most likely rejected for this reason with a 'margin' status shown.
Typically, it's better to target investing an amount slightly less than 100%, depending on the volatility and time period of your instrument.
I' m not sure what's going on. I've double checked your code and it is correct. Your error message is unfamiliar to me so I cannot comment. There must be an issue with the data perhaps? Have you tried running a simple ohlc through your formula to make sure btalib is functioning correctly?