How to return industry rank - not stock rank

I want to setup the scanner to return industry ranks - not stock ranks. By industry rank, I mean what the current Data->Industry Sector returns. Is there a way to do that?

There are several methods and they produce different results.

The returns you see Data→Industry and Sector are using a cap weighted average time series that compounds daily returns (btw, you can see these series in the Technical Chart of the stock pages). To use these time series you write something like this

%(close(0, #sector), close(21, #sector))

Also, what you see in Industry and Sector pages is not actually a rank. It’s simply color coded based on ranges of relative returns. So for example 3% or better relative return gets the strongest green, 1.5% to 3% gets more faded green, etc (not quite sure the exact limits are).

You could code what the Sector and Industry page does with a bunch of evals. but it’s long and tedious.

Alternative 1

A better way is to calculate the rank position of the sector return vs other sectors (or subsector/industry). This can be accomplished using the FOrder cross sectional function. But since FOrder was meant to return the rank position for each stock, a special trick is needed… You can do it this way:

@1Mo:(%(close(0,#sector), close(21,#sector) ) )
@SecOrder:( FOrder("@1Mo", #all, #desc, TRUE) )

The above will return 1 for the stocks in the sector with the best 1M return, 2 for the second best, etc. The “trick” is the 4th parameter of FOrder, called unique, which when TRUE returns the order of distinct values.

Alternative 2

If you do not want cap-weighted sector returns you could calculate the average 1Mo return of all the stocks in the Sector using Aggregate. It would look something like this

Aggregate("%(Close(0), Close(21))", #Sector, #Avg, 16.5, #Exclude, FALSE)

You can see the difference with cap weighted in this screen I made public. Note that Aggregate is based on the universe. So the average sector performance using the SP500 universe will be different than the DJIA universe.

Alternative 3

Use a ranking system with Sector or Industry nodes. I created an example here. It’s entirely made up of Sector nodes and also allows you to rank a sector based on more than one factor. I called it “Sector Acceleration” because it gives higher weight to more recent performance. See the image below.

There you have it. Sorry I turned a simple question into something quite complex.

image