Taking your custom technical ranking system further
Last time we looked at ways to create a custom ranking system using simple scripting formulas based on a number of technical conditions, and in this article we’ll look to take it a step further by calculating breadth measures on a universe of stocks, and also adjusting the weightings.
As a reminder, here’s the formula for the ranking system we created:
//Currently trading above the MA50?
V1 = CLOSE()> MA(BARS=50, CALC=Close);
//The 13EMA is sloping up?
V2 = MA(BARS=13, STYLE=Exponential, CALC=Close) IsUp;
//Is the MA33 is above MA88?
V3 = MA(BARS=33, CALC=Close) > MA(BARS=88, CALC=Close);
//Is the RSI(10) above its 10MA?
V4 = RSI(BARS=10) > MA(RSI(BARS=10), BARS=10);
//Positive returns over last 3 months?
V5 = ROC(Month(PERIODAMOUNT=1), BARS=3) > 0;
//Sum the results to get a ranking value
This will create a daily value for of between 1 and 5 for each stock in a universe, for each day. Enterprise Services clients (or those who have purchased the add-on module) will be able to create a daily Market Breadth measure of the number (or percentage) of companies in a universe with any ranking value, such as the percentage of fives, or a range, such as >=4.
(For a refresher on Market Breadth see Mathew’s recent article on Volatility Swings.) Let’s say I want to create a time series of the percentage of stocks in the ASX200 index with a ranking value of 5, ie the strongest companies as defined by my system. To do that we can use the same formula used to colour the ‘5’ bars as described in the previous ranking blog, ie using this as the last line to find those with a value of 5:
Using the complete formula in the Market Breadth module (located under the Data menu) we can then create the ticker symbol (in this example MYRANK5), give it a name, define the universe of stocks (ASX Top 200 in this example, but you could run it over an imported list of your own portfolio tickers), Date Range (calculates the percentage every day for the last 5 years), timeframe (daily) and Breadth Action (percentage). Once set up, click Build Breadth to calculate the values.
Currently, almost half of the ASX200 companies (44.5%) have a ranking value of 5, the highest percentage in almost two years. When added to the chart of the index (XJO), you can see a couple of divergences between the two charts, indicating a possible change in direction. For example at the turn of the year the XJO was making higher highs, but the breadth line was doing the opposite and making lower highs (ie fewer strong stocks), indicating a possible end of the move. Also, in April the index made new lows but the breadth line didn’t – just before the market rallied.
Adjusting the Component Weightings of the System
As well as creating breadth measures, it’s also possible to change the weightings of the ranking criteria. Let’s say that you consider the shorter-term V2 measure (is the 13EMA sloping up?) to be the most important of your 5 measures, and the V5 measure (positive returns over 3 months?) the least important, with the others remaining equal. Remember that the script formulas will give a value of 1 when a condition is true and 0 if false, so to adjust the weighting we just need to multiply the results by our weighting value. In the above example, we’ll increase V2 by 25% and reduce V5 by 25% so the last line of the example would be as follows, remembering to use the parentheses:
Of course, such a change would mean that instead of possible results of 0, 1, 2, 3, 4, or 5 you could now get totals of 0.5, 1.5, 2.5, etc:
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, UK and currently USA, Darren has a broad understanding of the individual needs of traders and investors utilising a wide range of methodologies.
In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and in October 2017 passed Level 2 of the CMT Program.
When not looking at charts, Darren keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in Charlotte, North Carolina with wife Wendy and their labrador, Gabba.