The traditional way to treat the RSI is to treat low RSI levels as good buying opportunities while treating high RSI levels as selling opportunities. However, we seek to gain fresh insight into the nature of RSI, with an eye toward discovering possible momentum return, by exploring the RSI using a visual quantitative approach.

#### Exporting And Visualizing The Data

We are interested in the next day returns of the RSI(2) for the E-mini S&P 500 (ES) futures contract. We will be using Tradestation and Excel for this analysis. For computing next day returns, we export the RSI(2) level and the close to close returns. We can export CSV data from Tradestation using the toolbox. However, I often find it convenient to print the data directly to the output window using Easylanguage, and then simply copy and paste it into Excel.

variables:

firstBar(1);

value1 = Rsi(Close,2)[1];

value2 = Close-Close[1];

if firstBar = 1 then begin

print("Date", ",", "RSI 2",",", "Close Close Change");

firstbar = 0;

end;

print(datetojulian(date), ",", value1,",", value2);

Now with the data properly in Excel, a scatter plot can be generated.

The Y-Axis shows the next day returns for the given RSI value, as represented by the X-axis. We can see that when RSI values are low that the market tends to be more volatile but beyond that it is difficult to read much more from this chart thus I introduce the concept of the cumulative return scatter plot.

A cumulative return scatter plot shows the total return for given RSI ranges. We can generate a cumulative return scatter plot by breaking the RSI down into a series of distinct classes or buckets and performing a rolling sum for those buckets. This can be performed in Excel. But, due to the number of rows, I found it more productive to generate a strategy optimization report and export that into Excel.

//RSI Class Generator

inputs:

RsiLevel(20);

variables:

RsiEntryLevel(0);

If Rsi(Close,2) >= RsiLevel-20 and Rsi(Close,2) < RsiLevel then

buy this bar at close;

If marketposition > 0 then

sell this bar at close;

Optimizing the RsiLevel from 20 to 100 in steps of 20 will yield the report we need to create the cumulative return scatter plot.

This chart reveals that the ES has primarily been a mean reverting market over a couple days. Momentum or trending returns might only manifest over longer holding period, however. With a slight modification to the previous code, we can test the RSI returns over various holding periods.

inputs:

RsiLevel(20), DaysHold(0);

variables:

RsiEntryLevel(0);

If Rsi(Close,2) >= RsiLevel-20 and Rsi(Close,2) < RsiLevel then

buy this bar at close;

If marketposition > 0 and barssinceentry > dayshold then

sell this bar at close;

We optimize both inputs to generate a new strategy report which can be used for visualizing the RSI returns over a range of holding periods. We look at returns from selling the next day up to 5 days out (where days refers to the value for our DaysHold variable– the actual number of days will be 6 or 7 depending on whether you want to count the overnight as the first day). Exporting to Excel, we can generate various heatmap displays.

The first heatmap shows the returns sorted by RSI class and number of days held. The second heatmap is sorted by net profit. The heatmaps reveal that buying weakness, at least as measured by RSI(2), even when holding up to 5 days out tends to be better than buying strength. However, it is also clear that some profits are being generated from modestly to moderately overbought conditions.

For maximal clarity, we can create a 3d bubble chart which will allows us to extend our cumulative returns scatter plot concept with the 3rd dimension. The custom 3d bubble chart below provides exceptional clarity into both how various holding periods affect specific RSI classes and how returns from different classes compare to one another on a relative basis. The size and color of the bubbles convey the magnitude of the gain or loss for each class while the X-axis shows the class with the Y-axis represents the holding period.

#### Summary

Our custom 3d bubble chart reveals quite a bit. First, it reveals that RSI levels under 20 are the most optimal. Yet, even when trading the RSI in a mean reversion nature, additional profits may be gained by trading more aggressively. Specifically, it looks like RSI class 40 (values 20-40) shows strong returns when holding for up to 1-5 days out with 2 days appearing to be the optimal. *The additional profits, however, won’t be cumulative because some trades will result in the RSI dipping even lower after entry. *

**As for momentum returns, we do see that there does appear to be, an albeit weaker, momentum driven return for RSI values from 60 to 80 when holding from 1 to 3 days out. On the other hand, extremely overbought conditions exhibit a strong reversionary nature. The returns from buying such extremely overbought conditions are very negative even when allowing for holding periods of up to 5 days out.

*Note all reference to days references the value of the variable, you would add 1 or 2 to get the actual number of days out depending on whether you want to count the overnight as the first day or not. Tradestation counts the entry bar as the first day. Adding code to sell at the open would enable seeing the overnight returns.*

–by Curtis White from blog beyondbacktesting

Thank you for this great stuff !!! I really like this kind of approach !

Greetings from Italy

Giovanni

Not the same after 2017. When market change in regime you are exposed to fat tail risk with this kind of approach. After all i think that the best way to use RSI in short term trading is trying to have a n average gain on average loss ratio costant! So it must necessary to introduce fixed target and stop. David from Italy.