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
Scope Parameter
Values |
Stocks |
ETFs |
Description |
#All | Y | Y | Operates on current universe |
#Previous1 | Y | Y | Operates on the results from previous rules |
#GroupVar1 | Y | Y | Operates on groups based on value of variable @Group |
--------------------------- For Stocks Only --------------------------- |
#Sector | Y | | Operates within each Sector of current universe |
#SubSector | Y | | Operates within each SubSector of current universe |
#Industry | Y | | Operates within each Industry of current universe |
#SubIndustry | Y | | Operates within each SubIndustry of current universe |
--------------------------- For ETFs Only ------------------------------ |
#Family | | Y | Operates within each ETF Family |
#AssetClass | | Y | Operates within each ETF Class |
#Region | | Y | Operates within each ETF Region |
#Country | | Y | Operates within each ETF Country |
#Method | | Y | Operates within each ETF Method |
#Style | | Y | Operates within each ETF Style |
#Size | | Y | Operates within each ETF Size |
#ETFSector | | Y | Operates within each ETF Sector |
1Available only in the Screener and Custom Universe