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.
Clients with the custom breadth module are able to build their own breadth measures (for a refresher on Market Breadth click here for Mathew’s article on Volatility Swings.) Let’s say you 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 the 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 you wish to calculate the measure on (the ASX Top 200 in this example, but you could run it over any Symbol List or 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 percentage values with a ranking value of 5 for each day.
In the example above, at the time of writing only 6% of the ASX200 companies had a ranking value of 5, down from 35% at the beginning of the year. When added to the chart of the index (XJO) using the Breadth Data tool, you can see a divergence between the index and the breadth data, indicating a possible change in direction. For example, a year ago the XJO was making higher highs, but the breadth line started to make lower highs at the end of May (ie fewer strong stocks), indicating a weakening of the market internals before the end of the rally in XJO in August.
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, 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.