Array out of index after resampling data
-
Hi,
I was happy out testing my basic strategies until I introduced data resampling.I used to check the price of a next bar ahead and it worked fine but now I get:
return self.array[self.idx + ago]
IndexError: array index out of range
when executing this line of code, as long as I use positive number, I get the error:first_bottom = [(self.datalow[i]) for i in range(-8, 5)]
Now i can't get to see price ahead anywhere in the code, I tried lines attribute, but no luck either.Spend the whole day fiddling with the code, but as for being not a programmer, I cant figure out for myself.
If anyone could point me out to the right direction, I 'd very appreciate.Here is more snippets of my code that could clarify the reason of the problem:
def __init__(self): self.datalow = self.datas[0].low ....................................................... data = bt.feeds.GenericCSVData( dataname=datapath, # Do not pass values before this date fromdate=datetime.datetime(2018, 9, 9), todate = datetime.datetime(2020, 2, 2), timeframe = bt.TimeFrame.Minutes, compression = 60, ................. openinterest = -1) ....................................................................... cerebro.adddata(data) cerebro.resampledata(data,timeframe=bt.TimeFrame.Days,compression=1)
-
Backtrader is specifically designed not to allow looking ahead of the current bar. The mostly eliminates look ahead bias in the backtest. Have a look over here for more info.
-
I would re-write the code to use only available data.
-
@run-out well it was working fine with single data.I guess I need to find a way to cheat a system . For a noob it will be a big challenge :) . Thanks for your replays guys.
And by the way run-out, good look with the backtrader2.