Last value of limted pattern length
what I'm trying to do is getting the last value of pattern recognition as a line. The data that is used in the pattern should be limitted.
My current approach ending in an index error
self.pattern_len =min(len(self.datas.open)-1, 10) self.PATTERN_CDLHARAMICROSS = bt.talib.CDLHARAMICROSS(self.datas.open.get(size= self.pattern_len), self.datas.high.get(size= self.pattern_len), self.datas.low.get(size= self.pattern_len), self.datas.close.get(size= self.pattern_len))[-1] IndexError: array index out of range
I know it could probably be easier by just using the whole length for the pattern and just read the last value from the line.
(Would that mean in every bar/step there would be an complete array of the pattern recognition?)
Is the error, that it tries to establish the value before it has enough values? Why does my approach with min does not work?
To answer my own question:
def __init__(self): self.PATTERN_CDLHARAMICROSS = bt.talib.CDLHARAMICROSS(self.datas.open, self.datas.high, self.datas.low, self.datas.close) def next(self): self.log(self.PATTERN_CDLHARAMICROSS)
gives exactly what i wanted. No doubled arrays and limiting the time line makes no sense here if it is applied to the whole line.
Sorry for the stupid question.