Hi everyone!
I'm new to Quantopian and trying to use talib's ATR function to test some trading ideas. However, the function is always returning NaN. Does anyone have any idea of why this might be the case? Here's my implementation:
Request closes, lows and highs for last 4 days
closes = history(4, '1d', 'price')
lows = history(4, '1d', 'low')
highs = history(4, '1d', 'high')
Loop through context.stocks
for stock in context.stocks:
yesterday_ATR = talib.ATR(highs[stock][-4:-2], lows[stock][-4:-2], closes[stock][-4:-2])[-1]
today_ATR = talib.ATR(highs[stock][-3:-1], lows[stock][-3:-1], closes[stock][-3:-1])[-1]
log.info(str(today_ATR)+", "+str(yesterday_ATR))
#Always returns "nan, nan"
As you can see, I am interested in the three-day ATR for both yesterday and today. Any help would be much appreciated!