I am new here so apologies if this is very simple. I couldn't find a direct answer in the forum. Thank you in advance

 

I'm really confused with how to correctly use the rolling windows. I want to use it to get the following: 

  • most recent high and low
  • previous day's high and low
  • and day before previous high and low 
import numpy as np


class algo(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2016, 1, 1) # Set Start Date
self.SetCash(10000) # Set Strategy Cash
self.AddCrypto("BTCUSD", Resolution.Daily, Market.GDAX)
self.SetWarmup(3)
self.window = RollingWindow[TradeBar](2)
self.lowwindow.Add(data["BTCUSD"].Low)
self.highwindow.Add(data["BTCUSD"].High)
def OnData(self, data):

bar = data["BTCUSD"]

high = bar.High
low = bar.Low


prevdayhigh= self.highWindow[1]
prevdaylow = self.lowwindow[1]

prev2dayhigh = self.highWindow[2]
prev2daylow = self.lowwindow[2]

nextdayhigh = self.highWindow[self.highWindow.Count-1]
nextdaylow = self.lowWindow[self.lowWindow.Count-1]

insideday = np.where((( prevdaylow < low ) & (prevdayhigh > high)),1,
np.where(prevdaylow == 0.0, np.nan,np.nan ))

short_termlow=np.where(((low<prevdaylow) & (low<nextdaylow) & (high<nextdayhigh) & (np.isnan(inside_day.shift(1)))),low,
np.where(prevdaylow == 0.0,np.nan,np.nan))

short_termlow_outsideday=np.where(((low<prevdaylow) & (low<nextdaylow) &( low < prevdaylow ) & (high >prevdayhigh) & (high<nextdayhigh) & (np.isnan(inside_day.shift(1)))),1,
np.where(prevdaylow == 0.0,np.nan,np.nan))