I am a newbie for backtrader and I need for you help..
Let's say that I have a strategy concerning with average price (like the average price of last 5 days）
So I always need the last 5 days data, sure I can use a variable to track the index and use some thing like
n_avg = 5
hisrotical_prices = [self.dataclose[x - n_avg] for x in range(n_avg )]
# without considering the first 4 days from beginning
Any better approach for this?
And what if the strategy need all the historical data? I would expect better than this
self.idx = 0 #track the timeline
hisrotical_prices = [self.dataclose[x - self.idx] for x in range(self.idx)]
self.idx += 1
Because I think there's some reason that the framework hide the real
idx variable and I don't want to break it...
Thanks a lot!