Hi all,
I run the example about ATR in Quantopian help, I try with SPY and date_range (2015/05/01 -2015/05/05)
My fisrt code
high = history(40, '1d', 'high')
low = history(40, '1d', 'low')
close = history(40, '1d', 'close_price')
# Calculate the ATR for the stock
atr = talib.ATR(high[context.stock],
low[context.stock],
close[context.stock],
timeperiod=14)[-1]
print atr
output
2015-05-01 PRINT 2.01582660149
2015-05-04 PRINT 1.97759589997
2015-05-05 PRINT 2.01836594903
And second time I try with
high = history(30, '1d', 'high')
low = history(30, '1d', 'low')
close = history(30, '1d', 'close_price')
# Calculate the ATR for the stock
atr = talib.ATR(high[context.stock],
low[context.stock],
close[context.stock],
timeperiod=14)[-1]
print atr
output:
2015-05-01 PRINT 1.98596195586
2015-05-04 PRINT 1.95915123556
2015-05-05 PRINT 2.02193389204
Another bar_count and another value. Why it have this difference? I understand that in high = history(30, '1d', 'high') is only innit 30 or 40 bar, but I only use 14 so no things change in here.
Please help me,
Thanks