Testing RSI and developing a strategy with it.

Testing RSI and developing a strategy with it.

By Trading Trojan | Trojan Trading | 19 Sep 2021

So this is my first post since long ago so don't hate me yet. Today I wish to demonstrate only a surface scratching part of analyis which most traders unfortunately don't pay attention to, and give a few ideas when it comes to using one of the most popular trading indicators.

I was using a bit improved modified version of the strategy I'll show in
this post in forex. The interesting part is that it had more than 52%
success rate. Note that I'm a supporter of agile development model,
and I strongly believe in testing each component of a system, whether
it is an app, trading strategy, or something else, should be tested,
improved and replaced with better components.

The first component of today: RSI

You all know this thing. It goes 0-100 and the extremes are called
overbought and oversold. So you buy when it crosses below 30 and
sell when it crosses above 70. And of course, you lose money...

Now there's more ways to trade it, you can sell when it crosses below 70 and buy when it crosses above 30 to hunt for a reversal. You can also choose longer settings and trade when it crosses 50 for trend following.

But for the purpose of testing, we'll choose the first one with default settings (14).

Testing setup:

  • Asset which will be traded is BTCUSD
  • We buy when rsi crosses below 30
  • We sell when rsi crosses above 70
  •  Position size is equal to 2% of our portfolio
  • To exit we put a stop loss and take profit at 1:1 ratio.
  • I like to use dynamic stop sizing with ATR, so my stop price = entry price +(-) 1.5*ATR. You can try and set a fixed amount, it may give you better results, but the big moves will surely be missed.
  • ATR is the value of ATR inddicator with default settings when entry is signalized.
  • We enter only when candle where cross happens is closed.
  • We cannot enter another trade if previous one hasn't been closed.
  • Fees are not included because different exchanges have
    different fees, but the bid/ask spread is included.

Keep in mind that I have kept the parameters exactly the same as I did in forex, that means that variations of this strategy will probably work better on crypto, but this way I can say that I have avoided overfitting the algorithm.

Also, this might not be popular, but I'm using meta trader 5 to develop strategies as MQL5 is based on C++, which is a programming language that I'm the most comfortable working with.

First test

We will be testing this strategy on a 30 minute timeframe since January 2021 til September 2021. Starting balance is 10000 USD. Testing will be done on every tick and execution latency will be 50ms. This way we *attempt* to model imperfect execution conditions. Here's the balance/equity curve from the test.

7f74ac191e27e819962a06181c0c6b0e9db6226fd6c1112feb037a0e93566ad3.pngWe all see that this is a money burning machine, so why did I make this post? Well now we're starting to think...

The improvement

But what if we managed to do something with it? Well, we can change settings, but it won't help much, crossing the 50 loses a bit less, but let's add a few more screws and nails. I've adjusted the length of RSI to 2, and I also added a 200 SMA. So we do the same thing, but we only enter long trades when price is above 200 SMA, and short ones when it is below.

It looks something like in this picture:

Now when it comes to backtesting, we run it with the same setup.
Aaaaaaaand see:


Yeah, it doesn't work... But wait, look at the testing dates. Yeah, I've changed the testing period. Now we test it from 2020 to 2021, and look at the backtest data.


It has more than 50% win ratio, also notice how the curve behaves near the end. If we run the backtest again, but with the same date as the first backtest: Now the results look like this:



So what does all this mean? It means that market conditions change, that a losing strategy can become winning one and vice versa. It means that you don't have to have a perfect strategy, you just have to deploy the right one at the right time. Also this is about half of the strategy I used in forex, I'm not an idiot to give out everything, but it's something you can play with and build on, try different exit methods. I hope that you've enjoyed reading. If you have any questions, suggestions feel free to write! Also please excuse me for the screenshots cut improperly, I'm still configuring my machine and testing environment that it will take some time until I finish everything up.

How do you rate this article?



Trojan Trading
Trojan Trading

Technical analysis and trading strategies ideas and testing.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.