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
kbrooks323 Hello would someone be willing to release a scan code for this? that would be helpful as I s...
Nicolas You can do easily this screener by using the assisted creation tool. It would take you about...
kbrooks323 I just figured it out thanks!
Vinks_o_7 Vonasi you're a beast !!! ;-)))
pableitor Amazing indicator , you are pushing PRT to the limit! But looking at the scatter its not c...
Vinks_o_7 Thanks Doc !
Maxime Baudin Intresting, thank you!
Zigo
4 years ago
fifi743 Good morning, there is no mistake about the shorts c11=SMI[14,3,5](close)>-40
Zigo has to be c11=SMI[14,3,5] < -40 (indeed)
xar3 Thank you ;-) Zigo
Sapo Thank you very much. as always your indicators are extremely effective. kind regards Vonasi.
mitsu21 Hi, it looks nice. I'll try it tomorrow thank you for your share kind regards bruno
kj1988 Thank you Vonasi for sharing this indicator. Very useful as a comfirmation to the price act...
ggolfet Thanks Nicolas, I imported the itf file and solved the problem.
Hasardeur Hallo Nicolas, i tried to code the multi period heat map in combination with the Ehler’s ...
Nicolas Please open a new topic with the code in forum.
Marie-Eve Vergoz lorsque je copie les codes, le système me signale des erreurs à la ligne 12 et suivantes
Marie-Eve Vergoz sorry - tout est ok -
AlgoAlex
5 years ago
Marcot18 Alex ti sei superato
AlexF Esagerato!
jobswaps Sube como trazar lineas de tendencias a tantas barras
Frankiesc interesting indicator !! Thanks for sharing!!!
robertogozzi Thank you :)
JJ Tec Hola Las condiciones de entrada / salida vienen en el libro de J. Carter Mastering the trad...
Pixeldd Ich bekomme beim einfügen des Indikators einen Fehler angezeigt. Was bitte muss ich genau än...
HarryPro Hello, Firtly there appears to be a typo on line 6 "lenghkc=20" should this be "lengthkc=...
sir_i Bonjour à tous, Je suis nouveau sur le forum et sur la plateforme, pourriez-vous me dire com...
Nicolas Il faut simplement l'appliquer sur le prix.
sir_i Merci pour la réponse, je ne suis pas familier avec l'application de cette procédure simple,...
Nicolas Il s'agit d'un indicateur compatible avec PRT v11 uniquement. Pour éviter les erreurs de cop...
Sébi Intéressant. Merci pour ce partage Nicolas. L'indicateur ne considère pas les divergences ...
Nicolas ok, pour les divergences chacun voit midi à sa porte je dirai :) Vu qu'il n'y a pas de formu...
mcha merci bien et félicitations pour la réactivité avec laquelle il a été mis dans la bibliothèq...
soulintact Great indicator Nicolas, thanks!
cdc.andersson Hello, when trying to include this wonderful Dynamic RSI on my trading system i get the erro...
Rafyone Bonjour Nicolas et bonne année lol J'ai une erreur qui apparait concernant drawbarchart une...
Nicolas Je pense que tu n'utilises pas le bon éditeur de code, cette instruction est compatible uniq...
Exalaxe Hey, i just noticed you optimized this strategy. Could i see your new version, please?
Andrea.1981 sorry i add my code but it not enter why i dont know
Andrea.1981 this is code simply stop , and you can see another version for stop / Codice principale...
AntoGH how did you backtest it ?
PastaPesto @AntoGH , I dont know if you are asking me, but my backtest was made in an IS of 4 years bet...
Ridder @PastaPesto Do you still running this and how is the results? Thanks
dau710 Are the Bulls Blue & the Bears Red?
dau710 Many thanks :)
arnaudat Merci nicolas, j'ai déjà pris cette version et en plus je suis sur les futures. Par contre d...
ullle73 hi nicolas, when im making a strategy out of this i get the error "PRC_VWAP z-score" called ...
Nicolas Please open a new topic in the ProOrder forum section and post the code there in order to ch...
3agl3 voglio l indicatore

Top