Full Description
Returns the percentile rank for each stock based on user specified parameters for the formula, the scope and the sorting direction.
Parameters
scope: how stocks are grouped before ranking (see below)
sort: Direction of sort within the group
- #ASC ascending (lower is better)
- #DESC (default) descending (higher is better)
incl_na: How NAs are handled
- #InclNA (default) include NA values
- #ExclNA exclude NA values, assigning NA to such stocks
- #NANeutral set NA values to 50
sort_style: How NAs are handled
- #Top (default) ranks are biased positively
ties are assigned the highest rank, and the minimum rank is 100 / n
- #Neutral ranks are neutrally distributed
ties are assigned the average rank, and the minimum rank is 0
It works like this:
- The formula in quotes is evaluated for all the stocks in each scope. 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 'sort' parameter. If you selected a sector scope multiple sorts are executed for each 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.
Special cases:
- NA's, if included, are always placed at the bottom of the array and all get the same percentile. The percentile assigned is the next percentile below the last meaningful value
- 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)
Examples
1) 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)
2) Rank in three groups: stocks that have a yield = 0, yield less than 5%, and yield of 5% or more. Then return the stock in each group with the highest MktCap.
SetVar(@group, Eval(Yield=0, 0, Eval(Yield > 5, 2, 1)))
SetVar(@rank,FRank("MktCap", #GroupVar, #DESC))
@rank=100 // return the biggest stock in each group
Copy and paste the above in the screener's text editor. This produces these stocks in Sept 2024:
For Yield = 0: AMZN
For Yield between 0 and5: AAPL
For Yield > 5: VZ
Show more details