The revised FRank() is live. It’s has a simpler parameter list and a new functionality with the #Param type. Here’s the new documentation
FRank(‘‘formula’’[,type,sort]): Ranks stocks based on a formula and returns the percentile.
Parameter ‘type’: Determines how stocks are grouped before ranking each group’s constituents from 100 to 0.
Values STOCKS ETFs Description
#Universe Y Y Ranks within selected universe
#Industry Y Ranks within selected Industry
#Sector Y Ranks within selected Sector
#Previous(1)Y Y Operates on the results from previous rule
#GroupVar(2) Y Y Operates on groups based on value of variable @Group
#Family Y Ranks within each ETF Family
#AssetClass Y Ranks within each ETF Class
#Region Y Ranks within each ETF Region
#Method Y Ranks within each ETF Method
#Style Y Ranks within each ETF Style
#Size Y Ranks within each ETF Size
#ETFSector Y Ranks within each ETF Sector
(1)Available only in the Screener & Custom Universe (2)Not available in Ranking Systems
Parameter ‘sort’:
#ASC- ascending
#DESC- descending (DEFAULT)
Examples:
Rank within each sector by the ratio of the latest price divided by price 5 bars ago (1 week return)
FRank("Close(0)/Close(5)",#Sector,#DESC)
Rank in two groups: stocks that have a yield and stocks that do not. It then returns the two highest ranked stocks from each group
SetVar(@Group,Yield>0)
SetVar(@rank,FRank("MktCap",#GroupVar,#DESC))
@rank=100
Logic:
-The formula in quotes is evaluated for all the stocks in the universe. The formula could be a single factor, like “MktCap” or more complex like “Close(0)/Close(10)”.
-The results are placed in an array
-The array is sorted using the ASC/DESC setting. If you selected within a sector or industry, multiple sorts are executed for each industry or sector.
-A percentile is assigned to each stock. This is the value returned by FRank. For example: if your universe is 500 stocks the top stock in the array gets 100, the next one 100 - 100/500 = 99.8, the next one 99.6 and so on. If you rank within and industry/sector you’ll have multiple stocks with 100, and the rank-delta’s (the rank difference between two consecutive positions in the array) will be different depending on how many stocks are in the industry or sector.
Special cases:
-NA’a are always placed at the bottom of the array and all get the same percentile. The percentile
-Equal values get assigned the same percentile. The next non-equal value gets a percentile equal to: ( percentile of the equal values) minus (number of equal values * rank-delta)