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?

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

  1. Nicolas • 06/28/2017 #

    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 • 06/28/2017 #

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

    • Nicolas • 06/28/2017 #

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

  3. larouedegann • 06/28/2017 #

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

  4. CKW • 06/28/2017 #

    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 • 06/28/2017 #

    works wonderfully with the russel

  6. Francesco78 • 06/28/2017 #

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

  7. Wilko • 06/28/2017 #

    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 • 06/28/2017 #

    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 • 06/28/2017 #

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

  10. CKW • 06/28/2017 #

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

  11. Wilko • 06/28/2017 #

    Thanks!

  12. StantonR • 06/28/2017 #

    Got good results on ZAF 1hr timeframe

  13. Wilko • 06/28/2017 #

    Great!

  14. Wilko • 06/28/2017 #

    Thanks for letting the community know!

  15. Mattzi • 06/28/2017 #

    Hi Wilko! Is there a screener for this one? Trying to make one myself but cant seem to get it right. Thank you!

    • Wilko • 06/28/2017 #

      I am not familiar with the screener function, but I am quite certain it should be quite simple to adapt.

  16. Gubben • 06/28/2017 #

    @Wilko have you had a look at this again since MTF support? Heard you talk on Börssnack btw..

  17. Wilko • 06/28/2017 #

    @Gubben not really. It was something I posted to show that simpler is usually better. Hope you enjoyed Börssnack!

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+2 more likes

Related users ' posts
luxrun grazie Ivàn!
lee Thank you. Is it possible to convert this to a screener that displays instruments when bulli...
Iván //---------------------------------------------------------------// //PRC_Pollan Indicator /...
Faisalx ChatGPT Hola Iván. Gracias por tu excelente trabajo. Te agradecería si pudieras echarle un...
Iván ok, perfecto! me pongo con ello
Iván
7 months ago
Iván Hi, Sorry, but what do you mean?
luiskohnen Hola, queria saber si el indicador repinta, porque a mi me parecio que si. Saludos y gracias...
Diamant Bonsoir, L'un d'entre vous peut-il me donner les définissions de LL-HH-LH et HL. Merci d'av...
Bernard13 (Je réécris mon commentaire -français- en français car certains mots ne correspondaient pas ...
Iván 1000 indicateurs !!! brutaux
Lean Me parece muy buen indicador, y se complementa muy bien en mi sistema, ¿podrías crear un scr...
Iván Gracias! Para el screener sólo tienes que copiar el indicador y poner como condición de búsq...
Lean Muchas gracias Iván, ya lo he podido crear.
Bateson
12 months ago
Matriciel Very nice job ! Is it possible to do the opposite because what interests me is to have the ...
YvesRobert Hi Matriciel, how can we do this, because stochastic is limited between 0 and 100 but price ...
Traderfox06 Dear zeiiermantrading, I really like your approach combining adaptive averages with MACD in...
jacquesgermain Hello IASD it's normal , when this occurs, uncheck RSI and MFI line and click then the MAC...
emiliobercial Thank you very much for sharing!
Carlose estoy de acuerdo con IASD Esta muy bien el MAD y el indicador en el precio no se ven bien...
bousalahane merci pour le partage de cet l'indicateur, j'ai rajouté un autre indicateur pour faire une s...
joaoarcher Hi, thank you for the this. Is it possible to create a screener from this indicator, so that...
ThaNoizy Yes, you cannot use CFDs on IG for Weekly strats you need to use their Index Futures, they h...
KumoNoJuzza Thanks. I did not know IG had Futures. I am always missing an info or a detail. I used to th...
joaoarcher Hi, thank you for the this. Is it possible to create a screener from this indicator, so that...
Nicolas
2 years ago
3 RSI
3 RSI
2
Indicators
Violet Nicolas, you calculate iRSI, but don't use it. You show RSI in the returned values, which, a...
Nicolas Yes, that's an error. RSI instruction is set by default to 14 if you don't indicate it that'...
Patrice210 bonjour STANKO, effectivement la première ligne apparait en anomalie et je ne comprend pas v...
KumoNoJuzza Hi guys, Thanks @Stanko and everyone for your contributions. I have been playing around ...
Stanko Hi KumoNoJuzza, thanks for the post. I also tried your code with Dax and the performance is ...
DELBERT Bonjour , Nicolas , je voudrais installer cet indicateur sur ma PRT , version 10.3 , mais je...
Nicolas En effet, il faut à minima une version 11. La 10.3 est tellement ancienne maintenant.. Je pe...
DELBERT Bonjour , Nicolas , merci pour ta réponse , je fais un essai et je verrais . Salutations .
Khaled Thank you Nicolas! Looks like TDI (Trader Dynamic Index). Interesting to give Exit Signal as...
Nicolas ColorBetween is an instruction added last year: https://www.prorealcode.com/documentation/co...
finplus Bonjour, serait-il possible de remplacer l'écart formé par les bandes de Bollinger par l'ATR...
AntoGH Bonjour peut-on backtester cela ? Et si vous l'avez fait pourriez vous nous donner le code.....
Nicolas désolé c'est un oubli de ma part, tu peux supprimer cette ligne, elle n'est plus utile dans ...
DELBERT Bonjour , Nicolas , merci pour ta réponse , je suis en effet avec PRT 10.3 , et j'ai bidouil...
supertiti https://zupimages.net/viewer.php?id=20/50/2e3v.jpg
volanirina Bonjour Je souhaite l'avoir sur l'indicateur MT4 si possible s'il vous plait. car je l'ai fa...
Nicolas ProRealCode est un site dédié à l'utilisation de la plateforme de trading ProRealTime: https...
Pensera Bravo Nicolas ! Tu es en quelque sorte l’inventeur de Metascore…(oups je viens de lire jusqu...
Nicolas Dans un but d'investissement pure, et non spéculatif.
Enigma08 Hi Juanj. I am new to ProrealTime and I am trying to program the Proscreener. I want the Pro...
Nicolas Please open a topic in ProScreener forum with your query, I'll reply you there. Thank you.
manafull Thanks Nicolas, I post my question, along with the codes I am trying to convert from your in...
Nicolas I replied to your post here: https://www.prorealcode.com/topic/screener-for-rsi-and-linear-r...

Top