Hi,

I am trying to get the ATR value before the open for each ETF in the symbols list.

but the line below is not working. Any idea ?

self.atr = self.ATR([i], 14)

 

class BasicTemplateAlgorithm(QCAlgorithm):
def __init__(self):
self.symbols = ['XLY','XLP','XLE','XLF','XLV','XLI','XLB','XLK','XLU'] # all sector

def Initialize(self):
self.SetCash(100000)
self.SetStartDate(2016,1,1)
self.SetEndDate(2017,1,1)
self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
# Before the open
self.Schedule.On(self.DateRules.EveryDay(self.spy), \
self.TimeRules.AfterMarketOpen(self.spy, -5), \
Action(self.beforeTheOpen))

for i in range(len(self.symbols)):
symbol = self.AddEquity(self.symbols[i], Resolution.Minute).Symbol
self.symbols[i] = symbol

def beforeTheOpen(self):
for i in self.symbols:
self.atr = self.ATR([i], 14)
self.Log("ATR: {0}".format(self.atr))

def OnData(self, slice):
pass

Thank you.

Chris