For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Last value of limted pattern length
-
Hi everyone,
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 errorself.pattern_len =min(len(self.datas[0].open)-1, 10) self.PATTERN_CDLHARAMICROSS = bt.talib.CDLHARAMICROSS(self.datas[0].open.get(size= self.pattern_len), self.datas[0].high.get(size= self.pattern_len), self.datas[0].low.get(size= self.pattern_len), self.datas[0].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[0].open, self.datas[0].high, self.datas[0].low, self.datas[0].close) def next(self): self.log(self.PATTERN_CDLHARAMICROSS[0])
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.