Backtesting a Strategy with the StockCharts Technical Rank (Python Tutorial)
I recently wrote a post on ‘How to implement the StockCharts Technical Rank’ in which I went over the steps on how to calculate the StockCharts Technical Rank (SCTR) for a group of stocks.
In this post I am going to put the SCTR indicator to the test and use it in a strategy that selects the stocks with the highest SCTR and holds them for a year.
This story is solely for general information purposes, and should not be relied upon for trading recommendations or financial advice. Source code and information is provided for educational purposes only, and should not be relied upon to make an investment decision. Please review my full cautionary guidance before continuing.
What’s the StockCharts Technical Rank?
The StockCharts Technical Rank (SCTR) is a proprietary ranking indicator developed by StockCharts.com, which ranks a stock in relation to it’s peers in a group of stocks.
The methodology for this ranking system was developed by John Murphy, a technical analyst who authored several books including ‘Technical Analysis of the Futures Market’.
You can find a detailed description of the SCTR on the stockcharts.com website.
In order to calculate the SCTR, Stocks are assigned a score based on six key indicators in three groups: long-term, medium-term and short-term. These scores are then sorted and assigned a SCTR rank.
The SCTR indicator is heavily used on the StockCharts.com website in charting tutorials, sample user charts as well as the analyst blogs.
And advantage of the SCTR is that it only uses price data and is relatively easy to calculate, that it considers multiple time frames and that it uses both trend and momentum indicators.
A disadvantage is that the framework doesn’t consider other common ranking criteria such as news & social media sentiment or company growth and value indicators.
Trade Ideas provides AI stock suggestions, AI alerts, scanning, automated trading, real-time stock market data, charting, educational resources, and more. Get a 15% forever discount with promo code ‘BOTRADING15’.
The Game Plan
So here are the steps we are going implement in this tutorial:
Get the list of S&P 500 components
For each symbol:
Fetch the last 10 years of daily data from Yahoo FinanceStart with a formation period 10 years ago and calculate the SCTR for each stock
Pick the top 5 stocks with the highest score and buy/hold for a year
Then continue with steps 3. and 4. moving the dates forward until today
Print performance stats for the strategy.
The idea of this strategy is to select the strongest candidates of the SCTR ranking system and hold them for a year in hope that they will continue their strong performance for the holding period.
As the Universe I used the S&P 500 just because the amount of price data needed to run this backtest is still manageable. You may want to backtest this strategy using a larger sample.