Taking your custom technical ranking system further

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.

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:

1
2
3
4
5
6
7
8
9
10
11
12
// 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
V1+V2+V3+V4+V5

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.

Calculating Breadth

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:

V1+V2+V3+V4+V5==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.

Breadth Setup Breadth Setup

MYRANK5 MYRANK5

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.

XJO Breadth XJO Breadth

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:

V1+(V2*1.25)+V3+V4+(V5*0.75)

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:

1 Day Watchlist 1 Day Watchlist

If you have any questions about creating your own ranking system or need help with scripting let us know. We have a free Scripting Forum where you can post questions, or if your requirements are more advanced then we also offer consulting services.