Print Page  
FORMULA FUNCTIONS / CROSS SECTIONAL
FOrder("formula" [, scope, sort, distinct, incl_na])
Full Description
Returns the order within the array for a stock or each group specified by the 'scope' parameter. FOrder operates as follows:
  1. The formula in quotes is evaluated for all the stocks in the universe for each scope. The formula could be a single factor, like "MktCap" or more complex like "Close(0)/Close(10)".
  2. The results are placed in an array
  3. The array is sorted according to 'sort' parameter. If you chose the Sector scope, multiple sorts are executed for each sector.
  4. An integer is returned that indicates the position in the array for each scope with one being the one on top. Stocks with equal values are placed in random position relative to each other (unless the 'distinct' parameter is set to TRUE).

Parameters

scope: determines how stocks are grouped before ordering (see below)

sort: Direction of sort within the group
     #ASC - ascending (lower is better)
     #DESC - descending (default; higher is better)

distinct: See below for an example
     FALSE - returns order within array (default)
     TRUE - returns order of distinct values of 'formula'

incl_na: Whether to assign an order to stocks with an NA value
     #InclNA - assign an order to stocks with NA values, always ordered after non-NA values (default)
     #ExclNA - assign an NA order to stocks with NA values

Distinct Parameter

When this parameter is set to TRUE the order is based on distinct values. This can be very useful when the formula uses, for example, industry values. For example to return all the stocks in the top three industries base on the 13 week Industry return, enter the following:

FOrder("Pr13W%ChgInd",#all,#desc,true)<=3

 
Scope Parameter

Values Stocks ETFs Description
#AllYYOperates on current universe
#Previous1YYOperates on the results from previous rules
#GroupVar1YYOperates on groups based on value of variable @Group
--------------------------- For Stocks Only ---------------------------
#SectorYOperates within each Sector of current universe
#SubSectorYOperates within each SubSector of current universe
#IndustryYOperates within each Industry of current universe
#SubIndustryYOperates within each SubIndustry of current universe
--------------------------- For ETFs Only ------------------------------
#FamilyYOperates within each ETF Family
#AssetClassYOperates within each ETF Class
#RegionYOperates within each ETF Region
#CountryYOperates within each ETF Country
#MethodYOperates within each ETF Method
#StyleYOperates within each ETF Style
#SizeYOperates within each ETF Size
#ETFSectorYOperates within each ETF Sector
1Available only in the Screener and Custom Universe