Hi, I'm trying to implement a simple EMA crossover strategy as practice for learning the Quantconnect platform, and when I use the consolidated bars with a rolling window, I can only seem to chart up to a certain point before the chart gets cut off. The backtest is supposed to be from June 2019 to March 2020, but this is the result:

 

https://i.imgur.com/LZF3Ikc.png

Here is the code I'm using:

from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Data.Consolidators import * from datetime import datetime, timedelta import decimal as d import numpy as np class ema_cross(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 6, 1) # Set Start Date self.SetEndDate(datetime.now()) # Set up cash and BTC self.SetCash("USD", 10000) self.SetCash("BTC", 0) self.crypto_pair = "BTCUSD" # Set up basic symbol and fee structure self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) self.AddCrypto(self.crypto_pair, Resolution.Minute) # warmup indicator #self.SetWarmUp(timedelta(minutes=6000)) # Define our EMA resolution, lookback and self.short_tf_resolution = 30 self.quick_lookback = 50 self.long_lookback = 200 # define ema_quick self.ema_quick = ExponentialMovingAverage(self.crypto_pair, self.quick_lookback) self.ema_quick.Updated += self.ema_quick_update self.ema_quick_win = RollingWindow[IndicatorDataPoint](5) # define ema_long self.ema_long = ExponentialMovingAverage(self.crypto_pair, self.long_lookback) self.ema_long.Updated += self.ema_long_update self.ema_long_win = RollingWindow[IndicatorDataPoint](5) ## Consolidator shortTimeFrameConsolidator = TradeBarConsolidator(timedelta(minutes=30)) shortTimeFrameConsolidator.DataConsolidated += self.shortTimeFrameHandler self.RegisterIndicator(self.crypto_pair, self.ema_quick, shortTimeFrameConsolidator) self.RegisterIndicator(self.crypto_pair, self.ema_long, shortTimeFrameConsolidator) self.SubscriptionManager.AddConsolidator(self.crypto_pair, shortTimeFrameConsolidator) def ema_quick_update(self, sender, updated): self.ema_quick_win.Add(updated) def ema_long_update(self, sender, updated): self.ema_long_win.Add(updated) def shortTimeFrameHandler(self, sender, bar): if not (self.ema_quick_win.IsReady): return self.ema_quick.Update(bar.EndTime, bar.Close) self.ema_long.Update(bar.EndTime, bar.Close) self.Plot("Short EMA", self.ema_quick) self.Plot("Long EMA", self.ema_long) def OnData(self, data): pass

 

Author