Hi,

I wrote a simple HMA strategy that includes a rolling window. In this strategy, I compare the current HMA value with the two-period-before HMA value. Somehow, the rolling window does not work. Can anyone take a look at it and tell me why?  TThanks

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from datetime import datetime, timedelta

class HmaAlgorithm(QCAlgorithm):

    def Initialize(self):
        ''' Initialize the data and resolution you require for your strategy '''
        self.SetStartDate(2018, 1, 1)
        self.SetCash(25000);

        self.qqq = self.AddEquity("QQQ", Resolution.Hour)
        
        self.hma = self.HMA("QQQ", 12, Resolution.Hour)
        
        self.hma.Updated += self.HmaUpdated
        self.hmaWindow = RollingWindow[IndicatorDataPoint](12)
        
        # Set WarmUp period
        self.SetWarmUp(12)
        
    def OnData(self, data):

        # Return if no data or if indicator is not ready
        if not (data.ContainsKey("QQQ") or self.hma.IsReady): return
    
        currentHma = self.hmaWindow[0]
        previousHma = self.hmaWindow[2]

        # Retrieve current price
        #price = self.Securities["QQQ"].Price

       
        if not self.Portfolio.Invested and currentHma > previousHma:
            self.SetHoldings("QQQ",1)
            
        elif not self.Portfolio.Invested and currentHma < previousHma:
            self.SetHoldings("QQQ",-1)    
            
        # Liquidate         
        if self.Portfolio.IsLong and currentHma < previousHma:
            self.Liquidate()
                
        elif self.Portfolio.IsShort and currentHma > previousHma:
            self.Liquidate()
                
    def HmaUpdated(self, sender, updated):
        self.hmaWindow.Add(updated)