I’m having some trouble understanding how to initialise, warmup and update a manual indicator. I made it work with the help of the documents, but I’m not entirely sure I understand how it works.

So, I have a dynamic universe and inside my AlphaModel in the OnSecuritiesChanged event handler I create a dictionary to save the security’s symbol and a reference to the SymbolData class. (Like the docs specify)

https://www.quantconnect.com/docs/v2/writing-algorithms/universes/key-concepts

Inside the SymbolData (nicely copied from the docs) it initialises an SMA indicator, it creates a consolidator which is used to Update the indicator and it warms up the indicator.

https://www.quantconnect.com/docs/v2/writing-algorithms/indicators/key-concepts

class SymbolData:
    def __init__(self, algorithm, symbol):
        self.algorithm = algorithm
        self.symbol = symbol

        # Create an indicator
        self.sma = SimpleMovingAverage(20)

        # Create a consolidator to update the indicator
        self.consolidator = TradeBarConsolidator(1) 
        self.consolidator.DataConsolidated += self.OnDataConsolidated

        # Register the consolidator to update the indicator
        algorithm.SubscriptionManager.AddConsolidator(symbol, self.consolidator)       

        # Warm up the indicator
        algorithm.WarmUpIndicator(symbol, self.sma)

    def OnDataConsolidated(self, sender: object, consolidated_bar: TradeBar) -> None:
        self.sma.Update(consolidated_bar.EndTime, consolidated_bar.Close)

    # If you have a dynamic universe, remove consolidators for the securities removed from the universe
    def dispose(self) -> None:
        self.algorithm.SubscriptionManager.RemoveConsolidator(self.symbol, self.consolidator)
        

Question #1: is this consolidator added for someone that wants to use a custom time to feed their indicator? Now the value of the TradeBarConsolidator is set to 1, so basically it is just created a consolidator which is redundant?

I removed the code of the consolidator and updated my SMA indicator after the initialisation line with CurrentSlice and the value I got in the backtest were the same. So, I assume I inferred the above correctly?

Question#2: the SymbolData class returns a SymbolData object so to access the indicator’s value I added a function GetIndicatorValue to the SymbolData class which I call from inside my Update() method in my AlphaModel class.

Is this the correct (or most efficient way) of accessing the indicator values?

Thanks to anyone that can bring some clarity!