Lets say that I developed an indicator to predict stock prices for the following 5 days.
I followed your tutorial and I could write a custom indicator class. But I couldnt assign the values for the coming 4 days for example. Maybe the following code will show the problem
class AlphayaPredictor(bt.Indicator):
lines = ('lstm',)
params = (('period', 5),)
plotinfo = dict(subplot=False)
# def __init__(self):
# self.addminperiod(self.params.period)
def next(self):
# datasum = math.fsum(self.data.get(size=self.params.period))
current_date = self.datas[0].datetime
prices = [[self.data.open[-i],
self.data.high[-i],
self.data.low[-i],
self.data.close[-i],
self.data.volume[-i]
] for i in range(self.params.period-1,-1,-1)]
pred_prices = predict_future_prices(prices) # it returns a list of future prices
for i in range(self.params.period):
self.lines.lstm[i] = pred_prices[i] # <---- here is the problem
# self.lines.lstm[0] = pred_prices[0] # <---- this is okay, but it's not my objective.
Could u plz tell me how to do it? I appreciate your help.