import numpy as np

class BasicTemplateAldgorithm(QCAlgorithm):

def Initialize(self):
# Set the cash we'd like to use for our backtest
# This is ignored in live trading

# Start and end dates for the backtest.
# These are ignored in live trading.

# Set Brokerage model to load OANDA fee structure.

# Add assets you'd like to see
self.eurusd = self.AddForex("EURUSD", Resolution.Minute)
self.usdcad = self.AddForex("USDCAD", Resolution.Minute)

self.eurusd_bb = self.BB("EURUSD", 16, 2.0 )
self.usdcad_bb = self.BB("USDCAD", 16, 2.0 )

def OnData(self, data):
# Simple buy and hold template
self.eurusd_holding = self.Portfolio['EURUSD'].Quantity
self.usdcad_holding = self.Portfolio['USDCAD'].Quantity

if(self.eurusd.Open > self.eurusd_bb.UpperBand):
#self.percent = .05
self.setHoldings('EURUSD', .05, True)

elif(self.eurusd.Open <= self.eurusd_bb.MiddleBand):
self.setHoldings('EURUSD', 0, True)



I am trying to learn how to use this api, but I keep getting an error "Cannot get managaed object"

The line that it lists as the cause is the commented line 'self.percent = .05' so I am guessing it is one of the lines before or after it.

from other posts, it looks like this is caused by trying to use an object without prepending 'self' to it, but I don't think I have forgotten it anywhere.

Can someone please tell me what this error means and how to fix it?