Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
RSI - Highest in 3 Years - Monthly Aggregation - PLEASE HELP

Hello,

I am trying to compare the current RSI with a Monthly Aggregation Period to the highest RSI value of the past three years. The goal is to buy a stock who's RSI (monthly) is the highest that it has been in 3 years.

Here is what I have. What must I do to fix the error? I have tried so many things but nothing is working.

Thank you,
Dante Migale

1 response

Im not sure if it posted correctly. Here is the code I am working on:

monthly_prices = ((data.history(context.assets, 'price', 14*21, '1d')).resample('1M', how='last', closed='left', label='left'))  
monthly_prices2 = (((data.history(context.assets, 'price', 50*21, '1d')).resample('1M', how='last', closed='left', label='right'))[1:36])  
#print monthly_prices2  
rsis = {}  
rsis2 = {}

open_orders = get_open_orders()  

for stock in context.assets:  

    rsi = talib.RSI(monthly_prices[stock], timeperiod=14)[-1]  
    rsis[stock] = rsi  

    rsi2 = talib.RSI(monthly_prices2[stock], timeperiod=14)[1:36][-1]  
    rsis2[stock] = rsi2  
    print rsi2  
    if (context.portfolio.cash > 100.0) & (stock not in open_orders and data.can_trade(stock))  & (rsi > rsi2.max()):  
        order_target(stock, 1)