Hello all,

I have created the vortex indicator, and I am trying to use it in a rolling window, however I am unsure as to how to go about doing this, as the class has no Updated() function and does not output IndicatorDataPoint class objects. Is it possible to do this? My Indicator class is below:

class VI: def __init__(self, period): self.Name = "Vortex" self.Time = datetime.min self.IsReady = False self.Value = 0 #arbitrary, not to be read - just outputted so as not to cause compiler err. self.Uptrend = 0 self.Downtrend = 0 self.queue = deque(maxlen=period+1) self.Period = period def __repr__(self): return f"{self.Name} -> IsReady: {self.IsReady}, Time: {self.Time}, Value: {self.Value}" def Update(self, input): self.queue.appendleft(input) self.Time = input.EndTime sum_trn = 0 sum_vm_uptrend = 0 sum_vm_downtrend = 0 lows = np.array([float(x.Low) for x in self.queue]) highs = np.array([float(x.High) for x in self.queue]) closes = np.array([float(x.Close) for x in self.queue]) if len(self.queue) == self.queue.maxlen: for i in range(0, self.queue.maxlen - 1): sum_trn += np.nanmax( np.array([ highs[i] - lows[i], highs[i] - closes[i+1], lows[i] - closes[i+1] ])) sum_vm_uptrend += abs(highs[i] - lows[i+1]) sum_vm_downtrend += abs(lows[i] - highs[i+1]) self.Vale.Downtrend = sum_vm_uptrend / sum_trn self.Value.Uptrend = sum_vm_downtrend / sum_trn self.IsReady = len(self.queue) == self.queue.maxlen return self.IsReady

 

Author