Hi all,

I have a problem that I need to change the period of an indicator on runtime when using custom time frames (2h). When using standard time resolution (1 minute, 1 hour, 1 day) I can just create a new indicator and feed it with the historical data, but not sure how to do this when using different time frames.

Thanks,

Simon

public override void Initialize()
{
SetStartDate(2018, 1, 1); //Set Start Date
SetEndDate(2018, 1, 2); //Set End Date
SetCash(_startingCash); //Set Strategy Cash

QuantConnect.Securities.Crypto.Crypto crypto = AddCrypto(_ticker, _resolution);

_baseSymbol = crypto.BaseCurrencySymbol;
SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Cash);

_consolidator = new TradeBarConsolidator(TimeSpan.FromHours(2));
SubscriptionManager.AddConsolidator(_ticker, _consolidator);
_consolidator.DataConsolidated += OnCustomHandler;

// how to change the period of this indicator on runtime and feed it with historical data?
_sma = new SimpleMovingAverage(_period);

RegisterIndicator(_ticker, _sma, _consolidator);

SetWarmUp(_period);
}

 

Author