Hey Guys!

I have been stuck on this for a couple days now and if anyone has any insight it would be hugely appreciated. Long story short I want to check the status of the 200day EMA vs the 50day EMA in order to determine if I want to enter a trade intraday. I currently have the add equity set to Resolution.Minute but want to set the EMA's to Resolution.Daily and then have the SetWarmup to 200days. Here is my current code

class WarmupAlgorithm(QCAlgorithm): def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' # Select ticker and amount of contracts self.ticker = "SPY" self.contracts = 100 self.SetStartDate(2019,1,1) #Set Start Date self.SetEndDate(2019,1,30) #Set End Date self.SetCash(100000) #Set Strategy Cash # Find more symbols here: http://quantconnect.com/data spy = self.AddEquity(self.ticker, Resolution.Minute) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) # MA Periods fast_period = 50 slow_period = 200 self.fast = self.EMA(self.ticker, fast_period, Resolution.Daily) self.slow = self.EMA(self.ticker, slow_period, Resolution.Daily) # Set the warm up period to the length of the slow period MA self.SetWarmup(timedelta(slow_period)) def OnData(self, data): # Plot the values of the various indicators self.Plot("EMAfast", "Value", self.fast.Current.Value) self.Plot("EMAslow", "Value", self.slow.Current.Value) # Warmup starts as True and once Warmup is complete goes to false which lets the algo run if self.IsWarmingUp: return if self.fast.Current.Value > self.slow.Current.Value: self.SetHoldings(self.ticker, 1) else: self.SetHoldings(self.ticker, -1)

If I remove the Resolution.Daily from the EMA's:

self.fast = self.EMA(self.ticker, fast_period)

Then everything works fine but the EMA will be based on a Minute period as opposed to the Daily period that I am looking for.

I have looked into self.History(symbol, 200, Resolution.Daily) to try add data prior to my intended start date but again couldn't get it to work. How do people typically pull in the required data for the indicators so that they are ready to run by the desired start date?

Any help is hugely appreciate and I apologize for the super simple question.

Seb

 

Author