Sectors Screener

I wonder if there is a way that I could screen for the stocks in the now top four current Sectors for the last week. If I did this now it would give me stocks in the Financials, Health Care, Industrials, and Utilities Sectors. Each week going forward or back of course the sectors would change somewhat.

This should work;

SetVar(@SectorAvg,Aggregate("Close(0)/Close(5)",#Sector,#CapAvg,10,#Winsor))
FOrder("@SectorAvg",#All,#Desc,True)<=4

You may need to adjust some of the parameters to exactly match P123 results.

Walter

EDIT: This is probably more P123 like;

SetVar(@SectorAvg,Aggregate("Close(0)/Close(5)",#Sector,#CapAvg,16.5,#Exclude))

Awesome! :slight_smile:

Thanks for the quick input. This really helps

When I tried the above expressions they did not work. However after doing some research through past threads of discussions on the screener forum, I came across the following expression:

Forder(“Close(0,#Sector) / Close(5,#sector)”,#All,#DESC,TRUE) <=4

This seems to do the job quite well.

They work for me. What was the issue?

Your approach is fine, too.

Walter

If I wanted to then apply another screener (using the same type of criteria) and get the top 10 stocks from the top 4 industries, is there way to do that? In effect, 1) get the best returning sectors (i.e. top 4 sectors), then 2) get the best performing stocks within those sectors (i.e. top 10 in each sector). This would then return 40 stocks, not 1000+

Simon

How about this;

Forder("Close(0,#Sector)/Close(20,#sector)",#All,#Desc,True)<=4
Forder("Close(0)/Close(20)",#Previous,#Desc)
SecCount<=9

SecCount must be the last rule.

I’m not sure how SecCount is implemented. It doesn’t seem to be indexing into an array, but rather acts like some kind of loop control. Dunno. But something like SecCount=1 doesn’t return any rows.

Walter

Thanks Walter. As you said, it sort of works. It would help if some of the documentation was improved around such functions. I find it pretty confusing to figure out exactly what is going on!

What I am really trying to do, is to investigate a drill-down strategy - first get the best performing sector(s), then the best performing sub sectors (within the sectors), then from those subsectors, identified the best performing Industries… then sub Industries… then stocks. But I cant really conceptualize how these functions work to investigate further. Effectively, what I want is the best performing N stocks from the best performing X Subindustries from the Y best performing Industries and so on and so forth. The criteria for “best performing” obviously can be anything - momentum, oversold, Market Cap, PEG, etc.

Simon