Generic RSI2 with modified filter

Generic RSI2 with modified filter

I have spent some time on the infamous RSI2 strategy. This is a well-recognized mean reversion strategy that has been posted previously on ProRealCode in various forms.

The rules are extremely simple to understand: Buy when 2-period RSI is below a certain threshold and sell when it has come back up again. The backside to the RSI2 strategy is you are exposed to negative asymmetry between max and average wins/losses, meaning every once in a while the market comes back and takes a big bite out of your profits, potentially big enough to wipe your account. In order to decrease that risk, it is often proposed to only employ the strategy when close remains above the 200 day moving average.

I propose to exchange the 200d MA for two rather simple conditions. Only employ when the slope of 22 day moving average is positive and a longer 22-period RSI remains above 50. I find these filters are an improvement on the original MA200-rule, although there is still a significant downside risk involved in this strategy.

I have only tested on IG CFDs, and it works quite well on most equity indices of developed markets. However, spreads on IGs 24h index CFDs at midnight (which is when daily strategies are executed on ProRealTime platform) will eat up much or most of the edge. Therefore I believe this strategy is best left until such time that ProRealTime allows access to two different timeframes from within the same ProOrder-strategy. I understand they are hard at work on this. In the meantime I provide the code as a potential source of inspiration.

 

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Nicolas • 143 days ago #

    At least Wilko has post something in the library! 😉 Thanks for this one, another great source of inspiration for our fellow coders around here, on this new fork of the classic RSI2 strategy.

  2. Wilko • 143 days ago #

    I have to admit it was a difficult birth…. 😉

    • Nicolas • 143 days ago #

      I have to say that I have difficulty believing you, I see magnificent equity curves from you on Twitter 😀

  3. larouedegann • 143 days ago #

    t-y for your code Wilko
    And the short entry ?
     

  4. CKW • 143 days ago #

    Thanks Wilko,
    I tried it on shorter time frame like 15m, 1h, 4h.. vs Daily. Result seems better than Daily. Do I miss something here? e.g. Wallstreet 2 spread

  5. Francesco78 • 143 days ago #

    works wonderfully with the russel

  6. Francesco78 • 143 days ago #

    sorry for my ignorance on this indicator, but would it make sense to try to build one wich allow  short positions too?

  7. Wilko • 143 days ago #

    Thank you all for your comments! I treat shorting very separately from the long side, at least in long-term growth assets like equities. When shorting, one is in that case going against the long term trend, meaning you are skewing probabilities against yourself from the outset. This needs to be taken into account. Also, in my experience, assets behave completely different on the up- and downside. Therefore I generally tend to try to treat short different from long. But gereally speaking, if you can get it to perform on the short side, then please do!
    If it works on 1hr timeframe, all the better! I did not get it to work, but I will test as suggested on the DOW.
    Again, thanks for all your comments, and happy trading!

  8. gabri • 130 days ago #

    Wilko,
     great code!! I never worked with RSI2 and I found it very interesting. I made some change to the code and I got good results on the stock market. I used a SMA200 slope and a weekly RSI14 (approximated by a EMA130 in the code) to get better trend information.
    ShortRSI = RSI[2](close)
    LongRSI = close>exponentialaverage[130](close)//RSI[22](close) //1 month RSI
    MA = Average[200,0](close) //1 month moving average of close
    Slope = MA/MA[1]-1 //Slope of 1 month moving average

    //MaxPos = 1 //Set to tolerated maximum position

    LongEntry = 1//CountOfLongShares < MaxPos //Buy until MaxPos reached
    LongEntry = LongEntry AND ShortRSI < 15 //Buy when RSI2 below 15
    LongEntry = LongEntry AND LongRSI //Filter for 1month RSI above 50
    LongEntry = LongEntry AND Slope > 0 //Filter for positive slope of MA22

    LongExit = LongOnMarket
    LongExit = LongExit AND ShortRSI > 60 //Exit position when RSI2 above 60

    // Conditions to enter long positions
    IF LongEntry THEN
    BUY 10000 cash AT MARKET
    ENDIF

    // Conditions to exit long positions
    IF LongExit THEN
    SELL AT MARKET
    ENDIF

    Cheers
    G

  9. Wilko • 128 days ago #

    I’m happy my code snippet inspired some new thoughts! Thanks for the feedback!

  10. CKW • 93 days ago #

    Thanks Wilko. I modified your daily strategy to 4H and tested WF on Dow Jon with acceptable SL.
    Great sharing from you!

  11. Wilko • 93 days ago #

    Thanks!

  12. StantonR • 23 days ago #

    Got good results on ZAF 1hr timeframe

  13. Wilko • 23 days ago #

    Great!

  14. Wilko • 23 days ago #

    Thanks for letting the community know!

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
juanj Definitely, need to code this into an automated strategy.
Marc Boliart dear nicolas, tyvm for your indicators and strategies, i have this following error when i ch...
Nicolas Your picture is too small, but for sure the problem is about the fact you are still using v1...
JMat45 Yes you can - as long as both timeframes are 2 hours or less (and shorter timeframe less tha...
Mirko Vaglio Interesting idea to bypass the limit of PRT about multiple timeframe, and I am just trying t...
Mirko Vaglio Looking a little bit more, now I understand what had to be absolutely obvious from the first...
Vonasi I'm a big fan of anything with Larry Connors on the SP500 with RSI[2]. I notice that your ex...
Francesco78 Hi Vonasi. The logic is based in the fact that the market has a bias to go up. This asymmetr...
Vonasi It seems that buy and hold outperforms this strategy. Removing the short side of the strateg...
alex Im looking for a entry when EpicMA crosses over/under trigger. Then look for exits when Epic...
JM David, Thanks a lot and next week I begin the test of this strategy in real... You have ot...
rejo007 hello david, i'll try it could you tell me wich strategy do you use in real? thanks
David Somogyi Hello, I have a couple of DAX strategies of breakout and mean reversion. I'll try to post...
juanj To follow new developments or get the latest version of this strategy please visit the forum...
tahar Hello Juan, I wanted to test Universal Strategy via a demo account on PRT but nothing happen...
BravoDelta @juanj wondering if you may help me please. I am looking for a simply strategy to use on the...
atlante je me demande si prorealtime pourrait etre programee sur fonction lorsquún point cgange de c...
lizmerrill can you provide this code for tradestation, please. Thanks
Nicolas No sorry, please use this file instead into a prorealtime trading platform.
lizmerrill can you explain the flow of the code, just to clarify. RE:fullness = (Dclose(0)-Dopen(0))/ab...
Francesco78 hi Lizmerril, yes, that is correct
lizmerrill Thanks for replying, so.... I assume in your backtest, the fullness calculations using dclos...
gabri GraHaL, I cannot see any link attached. I mostly manual trade but for stocks with strong fi...
GraHal Yes sorry, I set up a link to a screen shot on my google drive and then I got locked into th...
gabri Here's the thread https://www.prorealcode.com/topic/multiframe-rsi-of-rsi/
nwesterhuijs Did you change the Kijun-Sen to the "Standard Period x 2" and corrected the Senkou-Span B so...
nwesterhuijs Thanks, only saw it just now.
juanj For the latest version and discussions see the Ichimoku thread here: https://www.prorealcod...
diegofe_2000 cordial saludo NICOLAS , gracias por excelente indicador. ¿ es posible obtenerlo en MT4 ? ...
Nicolas Lo siento, pero no estoy trabajando para ayudar a la gente aquí de forma gratuita para promo...
diegofe_2000 Nicolas , gracias por tu atención. La pregunta era por curiosidad (yo no trabajo ni manejo ...
ALE
6 months ago
CSR strategy DAX 1 D
CSR strategy DAX 1 D
13
Strategies
Nicolas The code has been updated in the attachment of the post with the last version which contain ...
ALE Thanks as always Nicolas
Toto le Heros It looks very interresting. I have one question related to the following result in ProbackTe...
Maz
6 months ago
Francesco78 very nice, thanks!
finplus Thanks for the job. Which variables do you suggest for timeframe 1 hour? 
Maz Depends massively on your market and the volatility. I suggest using the variable optimizer ...
larmhen
6 months ago
HerveS_67 Bonjour, A quoi correspondent les données S, M, L ? Hello, What do the data S, M, L?

Top