Full Description
Returns the order within the array for a stock or each group specified by the 'scope' parameter. FOrder operates as follows:
- 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)".
- The results are placed in an array
- The array is sorted according to 'sort' parameter. If you chose the Sector scope, multiple sorts are executed for each sector.
- 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: How NAs are handled
#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
#NANeutral - assign a middle 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
Show more details