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.
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); value2 = Close-Close; 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.
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.
We will be offering a premium program for some of our articles. This article will be offered as our first premium program in the near future. The premium program will feature step-by-step video tutorials with detailed narration showing you every single step needed to recreate our work– everything from generating the optimization reports in Tradestation to generating the custom Excel charts will be demonstrated. Additionally, the premium package will offer expanded proprietary analysis that will go deeper then what we cover here. Plus, you get all source code ready to run–including additional strategy code, all the worked Excel workbooks, and the expanded additional proprietary analysis all for a reasonable price. As an added bonus, you will learn several of the tips and tricks I use when working with Tradestation to maximize my productivity. And last but not least, program purchasers receive limited exclusive email support.
If you’d like to be notified when the premium package is available then please let me know by shooting an email to email@example.com or simply click here to contact us using our contact form.
Curtis is passionate about markets. He has developed top ranked futures strategies. His core focus is (1) applying machine learning and developing systematic strategies, and (2) solving the toughest problems of discretionary trading by applying quantitative tools, machine learning, and performance discipline. You can contact him at firstname.lastname@example.org.
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.