Hello All,

I am looking for a little help with my algorithm. I have calculated the Hull Moving Average (HMA) of "SPY", then have taken 2-period (in my case 2 minute) percent change "slope" of the HMA as my indicator of when to Buy or Sell. What I want to do next and what I am having trouble with is creating a Simple Moving Average (SMA) of that "slope" with a period of 25. I have tried several different methods with no luck. I have attached the code that contains the HMA and "slope" calculations, This issue that I can't seem to get over is: I calculate the "slope" in the "On Data" section, but then I can't initialize the SMA with data that hasn't been calculated yet. Any help with creating an SMA of the "slope" would be great. 

Also, is there an easier to calculate the "slope" (even though it is only one line) by calculating the percent change of the HMA? Maybe a one-liner in the initialize section?

Thank you for your help.