Indicator history consolidator

Hi! I need to dynamically add/remove symbols in strategy based on indicator. 

How can i get consolidated history for my, for example, 30 mins SMA indicator and work with it?

Update Backtest

In order to save the data for an indicator, one can use a RollingWindow. A rolling window is an array of data that allows for reverse list access semantics. 

# In Initialize, create the rolling windows
def Initialize(self):
# Creates an indicator and adds to a rolling window when it is updated
self.SMA("SPY", 5).Updated += self.SmaUpdated
self.smaWin = RollingWindow[IndicatorDataPoint](5)

# Adds updated values to rolling window
def SmaUpdated(self, sender, updated):

In the code above, there is a RollingWindow that saves the last 5 SMA indicators. So when a 6th SMA indicator gets added, the 1st SMA added is now removed from the list. This window can be initialized to the size needed and consolidated calculations can be made by iterating through the object. If this does not suffice as a solution, it would be helpful to attach some sample code for guidance. 


Thanks for your answer, Gurumeher!

Here is my code. It's not actually what i'm working with, but it represents my problem. Each day at 11:00 we refresh our universe, i.e. remove everything and add new symbols. We working with 15-min bars, not 1-min! And we need to load from history 140 of 15min bars and calculate SMA.


Hi Maxim, 

You can use "PushThroughConsolidators" to send the historical price into the consolidators and warm-up the indicator. Please see the attached example


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed