For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
IndexError: array index out of range in next()
-
Hello,
I am facing the next issue.
This is my code:class ShortSuperTrend(bt.Indicator): lines = ('ShortSuperTrendUp',) params = (('atr_period', 14), ('Multiplier', 0.6), ) def __init__(self): self.atr = bt.talib.ATR(self.datas[0].high, self.datas[0].low, self.datas[0].close, timeperiod=self.params.atr_period) self.up = self.datas[0].low - (self.params.Multiplier * self.atr) self.up1 = self.up(-1) #self.lines.ShortSuperTrendUp = self.up1 def next(self): self.up = bt.If(self.datas[0].close[-1] > self.up, bt.Max(self.up, self.up1), self.up[0])
When using indexing with () in the
__init__()
I am getting the next error:TypeError: 'list' object is not callable
The assignment in the
next()
function produce the next error:IndexError: array index out of range
My wish is to update
self.up
with the expression's results for each candle.