I have a strategy which trades on the Minute resolution, with two consolidators - 15m and 4Hr. I used a number of indicators, one of which is the MACD, which is instantiated twice - once each for 15m and 4hr.

To obtain the previous MACD value for the 4Hr timeframe, I use a RollingWindow. However, when I tried to access a specific window data, I encounter a runtime error - 

 

Runtime Error: TypeError : Cannot get managed object
at OnData in main.py:line 105
TypeError : Cannot get managed object (Open Stacktrace)

Have I missed anything ? Here is my source code:

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.symbols = ["EURUSD","EURAUD","GBPUSD","AUDUSD"]
self.SetStartDate(2016, 1, 1) #Set Start Date
self.SetEndDate(2018, 6, 1) #Set End Date
self.SetCash(25000) #Set Strategy Cash

self.forex = self.AddForex(self.symbols[0], Resolution.Minute, Market.FXCM)
self.SetBrokerageModel(BrokerageName.FxcmBrokerage)

self.SetWarmup(100)

# Trade 15m and 240m timeframes
consolidator_15 = QuoteBarConsolidator(15)
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_15)
consolidator_240 = QuoteBarConsolidator(240)
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_240)

# Initiatialize indicators


self._macd = MovingAverageConvergenceDivergence(self.symbols[0], 12, 26, 9, MovingAverageType.Exponential)
self._macdTrend = MovingAverageConvergenceDivergence(self.symbols[0], 12, 26, 9, MovingAverageType.Exponential)


self.RegisterIndicator(self.symbols[0], self._macd, consolidator_15)
self.RegisterIndicator(self.symbols[0], self._macdTrend, consolidator_240)

self._macdTrend.Updated += self.MacdUpdated
self._macdWindow = RollingWindow[IndicatorDataPoint](3)

self.__previous = datetime.min


def OnData(self, data):

if self.IsWarmingUp: return



# only once per day
if self.__previous.date() == self.Time.date(): return

# wait for our macd to fully initialize
if not ( self._macd.IsReady and self._macdTrend.IsReady) : return


self._macdTrend.Previous = self._macdWindow[1]

# Problem code here on self._macdTrend.Previous

trendMACDUp = self._macdTrend > 0 and (self._macd.Current.Value > self._macdTrend.Previous)


self.__previous = self.Time

def MacdUpdated(self, sender, updated):
self._macdWindow.Add(updated)

Any help is very much appreciated. Thanks.