Being overbought does not mean sell!
As the S&P500 index recovered from its Christmas 2018 lows I began to see comments about the index being overbought, as measured by the Relative Strength Index oscillator, or RSI (not to be confused with relative strength against an index). Typically, an RSI measurement over 70 is deemed ‘overbought’, and below 30 is ‘oversold’ but because it’s a measure of momentum being overbought should not trigger a sell signal (and likewise oversold should not trigger a buy).
The S&P/ASX 200 index ($XJO) in Australia experienced something similar last month. The 14-day RSI crossed above 70 on February 5th following when it broke above resistance at 5900. But since then the momentum has taken it a further 4% – and three more crosses of RSI above 70:
So if you had sold on that first overbought signal you would have missed out on that subsequent rally!
Taking it to the stock level
Is there an easy way to identify those stocks whose RSI(14) has crossed above or below a certain level multiple times to identify strong positive or negative momentum?
Of course! The Optuma Scripting Language can be used to calculate custom tools and timecounts, and highlight bars when certain conditions occur.
Below is a chart of MSFT with the RSI(14) overbought level set to 66 and the oversold to 33. Why these levels rather than the standard 70 and 30? No particular reason, but I wanted to see if it worked better than the default settings in showing the strength and weakness earlier, but there’s no reason you can’t keep it at 70 and 30, or try 60 and 40, or 70 and 50.
The red Show Bar arrows indicate where the RSI(14) has crossed above 66 (overbought), and the green ones when it crossed below 33 (oversold):
Since July 2016 when MSFT’s RSI crossed above 66, it crossed above another 23 times until it finally reached oversold levels in October 2018 – 613 trading days since it was previously oversold. These values are calculated in the panels below the price chart using the following formulas in Show View panels:
Days Since Oversold:
V1 = RSI(BARS=14) < 33;
Number of times Overbought since last Oversold:
//Create 2 Boolean conditions
V1 = RSI(BARS=14) CrossesAbove 66;
V2 = RSI(BARS=14) CrossesBelow 33;
//Count the number of times V1 occurred since V2
The COUNTMATCHSINCESIGNAL() function requires two true/false Boolean scripts, and counts the number of times V1 has occurred since V2
Displaying the statistics in a watchlist
The above is a useful look at individual charts, but we can now use the formulas in a sortable watchlist to filter a universe and quickly find opportunities or see where a particular stock sits compared to others.
Here’s a watchlist of the S&P500 companies (with the same RSI(14) and 33/66 levels as the MSFT chart above) sorted by the number of overbought conditions since the last time it was oversold (the #O/B Since O/S column).
As you can see ORLY is ranked top with 15 occasions in the last 407 trading days since it was last oversold.
The first column O/B Since O/S gives a true/false result depending on if the RSI has been in overbought territory more recently than it was oversold. This uses the SWITCH() function as follows:
The last two columns shows the current RSI value and whether it is above the 45-day moving average. So whilst ORLY is top of the list its RSI is now in the 50s and below its long-term moving average, so you may want to keep an eye on the chart to see if this short-term weakness turns into something bigger.
To look at those stocks with negative momentum click on the column you wish to sort by, so in this example COF hasn’t been overbought for 280 days, during which time it has crossed into oversold territory 7 times.
Copying the Watchlist Data to Excel
If you wish to carry out further analysis in Excel then simply right-click on the watchlist and select Copy CSV Values to Clipboard from Actions, and then paste in to Excel (note that you may need to click on the Text to Columns option under the Data menu in Excel to format the data).
Also, Enterprise Services clients can send a watchlist dynamically to Excel under the Actions > Send To menu – this is particularly useful when linked to a realtime data provider as the values in Excel will automatically update when the watchlist updates in Optuma.
Optuma clients with access to our ASX or US end-of-day data can download an example of the above watchlist and charts. Click the buttons below to save an open the workbook and experiment with the formulas as you wish. Don’t forget to post any questions on the Scripting Forum, or contact us to arrange a consulting session.
Darren Hawkins, MSTA
Senior Software Specialist at Optuma
Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.
Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, the US and currently the UK, Darren has a broad understanding of the individual needs of traders, portfolio managers and investors utilising a wide range of methodologies.
In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and when not looking at charts he keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in the Essex countryside in England, with wife Wendy and their labrador, Gabba.