Hi, I am super new to Quantconnect Algorithms and was trying to update EMA bootcamp tutorial code such that it will automatically calculate slow(200) and fast(50) EMA values instead of manual updates. Code I am trying is:

  1. def CoarseSelectionFunction(self, universe):
  2. #initial code above
  3. # Create loop to use all the coarse data
  4. for coarse in universe:
  5. symbol = coarse.Symbol
  6. #2. Check if we've created an instance of SelectionData for this symbol
  7. if symbol not in self.averages and symbol is not None:
  8. #3. Create a new instance of SelectionData and save to averages[symbol]
  9. self.averages[symbol] = SelectionData(symbol,self.EMA(symbol,200,Resolution.Daily),self.EMA(symbol,50,Resolution.Daily))
  10. # above line throws error
  11. # remaining code below

When I try to directly call self.EMA(symbol…) I am getting an error :

Runtime Error: Please register to receive data for symbol 'SPY R735QTJ8XC9X' using the AddSecurity() function. in Indicators.cs:line 2448

Do I need to add all securities explicitly even after having them in Universe section functions?

Author

Log Up

July 2022