Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
RSI strategy - help needed

Hi there,

I have been trying to build a simple algorithm that buys small market cap stock (below 2M€) for which the RSI(14) is below 45 and RSI(7) is below 20.
Ideally, the positions should be hold on to until RSI(7) reaches 50.

Not sure my order to sell when RSI>50 works for stocks in portfolio? I have been trying to modify the value but keep getting the same results.
I don't understand where I am wrong. Could anyone please help?

Thanks !

Brian

5 responses

Anyone?

You are trying to use a pipeline factor to set the rsi_5 value outside of pipeline. I'm not sure, but don't believe that is going to work. Your screen is also exclusive of high RSI values, so as it stands your pipeline isn't going to contain the information you need for when to close out positions. You either need to allow stocks with high RSI values back into the pipeline or use the RSI function from talib to calculate RSIs outside of pipeline to determine when to exit. (check the Classic RSI2 Mean Reversion algorithm to see how to do that)

But I believe you have a bigger problem. Your n_stocks plot shows that your screen hardly ever returns more than 1 or 2 stocks. That doesn't give you a lot of activity to evaluate strategy performance with, or many opportunities to trade for that matter. $2 million is much too low to set as an upper limit.

You're also having problems filling orders, which is understandable because you tested with an account size of 10 million, and a weight per stock of 1/5 account value. That means your algorithm was trying to by $2 million worth of each stock, which equates to trying to buy these companies outright.

Mainly adding some tools. Increased market cap for more stocks and some other playing around without thinking too much.

                        min              mean               max  
marketcap         1845842.0     5987020.85714         7704596.0  
   rsi_14     2.32558139535     14.8112531422      36.301369863  
    rsi_5     7.46268656716     20.0177953699     36.5853658537  
    rsi_7               5.0     9.25093879312     14.3808255659 

    ... rsi_5 highs  
                      marketcap     rsi_14      rsi_5      rsi_7  
Equity(32323 [IMUC])  6648647.0  36.301370  36.585366   5.000000  
Equity(35088 [RSLS])  4993457.0  10.624071  25.961538  14.380826  
Equity(42528 [CHFS])  7704596.0  27.058824  19.148936   7.692308  
Equity(7842 [USEG])   7668132.0   4.545455  19.047619  11.764706  

RSI examples: https://www.google.com/search?q="import+RSI"+site:quantopian.com

Thanks Shawn Emhe II! That makes total sense. your feedback really helps.

BlueSeahawk, as I am quite new and do not master all coding part yet, I might get back to you with some extra questions on your input if that is ok? Thank you.

Hi Blue seahawk,

So is your algorithm only shorting stocks, and not longing any? I'm new to quantopian and just wanna make sure I'm getting that right.