you can't define xATRTrailingStop from the first line, it uses ATR with period 5, so only from line 6
bt.If, bt.Max etc can be used only in __init__()
self.xATRTrailingStop is defined in __init()__ so thishasattr(self,'xATRTrailingStop')` is always True
len(self.datas) returns numbr of the data feeds added to cerebro
self.datas[-1] - i don't think this object exists
xATRTrailingStop = bt.If(...) I don't think this line returns any meaningful results
I would recommend to review documentation one more time, go thru the Quick Start yo understand how to work with the data feeds and arrays in bt.
@vladisld Enjoyed the video. Believe the issue in the code was that it was iterating over rows and writing 1 row at a time to the database...
Can now write 13 years of 1 minute data in ~50 seconds. Needed to batch_size=10000 for it to work on a large data-set.
Problem solved. Now the real work begins.
@run-out said in What are different between bta-lib, ta-lib and internal BackTrader indicators?:
@Quỳnh-H-Nguyễn This is still an awesome tool. And if you wanted to create a line preloading into cerebro, this would make it dead easy. Cheers
yeah, I got some times and don't know the reason. However, it is simple for a rookie like me to begin!