Ranking, testing, tra la la

Hello fellow travelers,

Suppose I had a stock ranking system like Dorsey Wright Technical Attributes that ranks stocks from 0 through 5 and I wanted to test it to see how well it sorted the wheat from the chaff. What I would like to see is how well stocks ranked 6 did, 5 did, and so on through 0. I thought about using portfolio testing, but there is no way to know in advance how many stocks will be ranked at each level on any given day. It is clear to me how to do this in Python, each period collect the average returns for each tranche and chain them together. However, I think that AB might be able to do this much more easily. What do you think the best approach in AB is to unearthing this information?

Best regards,


Ranking is explained in the Users' Guide including 3 ways to do that and example codes:


Thanks for the reference Tomasz. I am actually familiar with, and quite like, AB's powerful ranking capabilities, but that was a good refresher. I often find that the articles are so dense with information that periodic rereading is quite useful.

What I was trying to ask about was not how to rank, but best practices for measuring the results of ranking when the number of items in each rank can be highly variable.

Something like this:
Period: 2006 through 2010
Universe: Russell 1000
Ranking: DR's Techncial Attributes
rank apr
5 12
4 8
3 4
2 0
1 -3
0 -5
Wouldn't it be nice if it came out like that, eh?

Maybe draw down and some other stats as well?

Best and thanks for the software,


If you want to run a portfolio backtest on one DW rank (tranche) at a time, then I think you could use something similar to a rotational strategy:

  1. Select the tranche to test. For this example, let's assume it's DW tranche 4.
  2. Decide on your "rotation" period: daily, weekly, monthly, etc. For this example, let's assume weekly.
  3. At the end of each week, count the number of symbols with a tranche of 4. Your position size for the following week expressed as a percentage of equity is then 100/count.
  4. At the start of the next week (Monday's open?), exit all current positions and then buy all the stocks that had a DW tranche value of 4 at the end of the prior week.

The advantage of this approach is that you can get some reasonable portfolio metrics (CAR, MDD, etc.) while keeping nearly 100% of your capital utilized. However, it may not be practical to trade, because even if the tranches are evenly distributed you'd be exiting and then entering around 166 trades each week if running against the Russell 1000. But I think it's fine as a way to estimate the value of a ranking/scoring system like DW, Zacks, etc.

Depending on your end goal, there are other approaches you could take as well. For example, you could trade ALL stocks each week, and then in the CBT you could summarize the trade metrics based on the stock's tranche. But generating all the portfolio metrics for each tranche would just be replicating a lot of work that AmiBroker normally does for you.

Hmmm... that seems like a good path. I will take a walk down it.



This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.