I have seen other threads but couldnt figure it out based on that.
class DataConsolidationAlgorithm(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.'''
self.SetStartDate(2017, 1, 1) #Set Start Date
self.SetEndDate(2020, 1, 1) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.SetBrokerageModel(BrokerageName.FxcmBrokerage)
symbols = [self.AddForex(ticker, Resolution.Minute).Symbol
for ticker in ["EURUSD"]]
self.SetBenchmark('SPY')
self.slow = self.EMA("EURUSD", 200, Resolution.Daily)
self.SetWarmUp(200)
def OnData(self, data):
# Simple buy and hold template
self.low = self.MIN("EURUSD", 7, Resolution.Daily, Field.Low)
self.high = self.MAX("EURUSD", 7, Resolution.Daily, Field.High)
#fxQuoteBars = data.QuoteBars
#QuoteBar = fxQuoteBars['EURUSD'].Close
#self.QuoteBar = self.History("EURUSD", TimeSpan.FromDays(1), Resolution.Daily)
self.quoteBar = data['EURUSD'] ## EURUSD QuoteBar
#self.Log(f"Mid-point open price: {quoteBar.Open}")
self.closeBar = (self.quoteBar.Close) ## EURUSD Bid Bar
self.history7days = self.History(["EURUSD"], 7, Resolution.Daily)
if self.closeBar <= self.low and self.Forex["EURUSD"].Price > self.slow.Current.Value:
self.SetHoldings("EURUSD", 1.0)
if self.closeBar > self.high:
self.SetHolding("EURUSD", 0.0)
Runtime Error: TypeError : Cannot get managed object at OnData in main.py:line 50 :: if self.closeBar <= self.low and self.Forex["EURUSD"].Price > self.slow.Current.Value: TypeError : Cannot get managed object