Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Complete Newb in need of a little help...

Hi guys,

I am trying to get this little piece of code to print out some values for one stock.

Mavg and price seem to be working fine, but when I get to ATR it claims it's not s number :(

I'm sure this is really simple, but if one of you seasoned veterans would take pity on me and explain to me what I am doing wrong, I'd really appreciate it.

Thanks a lot in advance

2 responses

Hey Jesper,

The reason you are getting a nan result for ATR is that the data is lagged by the number of days you specify for the time parameter. Check your log output and you will see that the ATR that is printed after about 20 days is not a nan value. You should be able to write a wrapper function in the IDE using history() that will not have a lag.

Best,
Ryan

Hello Jesper,

If you want to continue in 'daily' mode you can test for NaN:

def handle_data(context, data):  
    ATR_data = ATR(data)  
    stock_ATR = ATR_data[context.stocks[0]]  
    if np.isnan(stock_ATR):  
        return  

P.