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.''' self.SetStartDate(2017, 1, 1) #Set Start Date self.SetEndDate(2020, 10, 1) #Set End Date self.SetCash(100000) #Set Strategy Cash self.AddForex("EURUSD", Resolution.Minute, Market.Oanda) self.SetBrokerageModel(BrokerageName.OandaBrokerage) # create a 12 day exponential moving average self.fast = self.EMA("EURUSD", 5, Resolution.Daily) # create a 48 hour exponential moving average self.slow = self.EMA("EURUSD", 25, Resolution.Daily) self.SetLeverage = 1.0 self.SetWarmUp(timedelta(days=20)) self.SMA("EURUSD", 225).Updated += self.SmaUpdated self.smaWin = RollingWindow[IndicatorDataPoint](225) def SmaUpdated(self, sender, updated): '''Adds updated values to rolling window''' self.smaWin.Add(updated) def OnData(self, data): # wait for our slow ema to fully initialize if self.IsWarmingUp: return fxQuoteBars = data.QuoteBars QuoteBar = fxQuoteBars['EURUSD'] self.window = RollingWindow[QuoteBar](2)