I am trying to do a calculation that involves data from previous bars, (which I have created using Rolling Windows and added the price data into), and then calls itself from one bar ago as apart of the calculation. 

For Example (in the OnData function):


self.window = RollingWindow[TradeBar](3)


HP = (self.window[0].Close - self.window[1].Close) + HP[1]


But this leaves me with an error message that I am using HP before it is assigned. May someone help me out and explain how to get this recursion problem working?