Full Description
Calculates the median value of the formula within each scope. FMedian 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. If your scope is within a sector, for example, multiple sorts are executed for each sector.
- The median value of the formula is returned for all the stocks with non-N/A values. If an odd number of stocks exist in the array, it returns the middle value otherwise it averages the values of the two middle stocks.
Parameters
formula: any valid stock formula
scope: determines how stocks are grouped before median is calculated (see below)
exclude_zero: when set to TRUE 0 values are discarded (handy for factors like Yield). Default is FALSE
Examples:
Find stocks with market caps higher than industry median
MktCap > FMedian("MktCap",#Industry)
Find stocks with PE's less than the SP500 Median PE
PEExclXorTTM < FMedian("PEExclXorTTM ",#SP500)
Make two groups: stocks that have a yield and stocks that do not. Return stocks that have higher market cap in the respective group
SetVar(@Group,Yield>0)
SetVar(@median,FMedian("MktCap",#GroupVar))
MktCap > @median
Scope Parameter
Values |
Stocks |
ETFs |
Description |
#All | Y | Y | Operates on current universe |
#Previous1 | Y | Y | Operates on the results from previous rule |
#GroupVar2 | Y | Y | Operates on groups based on value of variable @Group |
--------------------------- For Stocks Only --------------------------- |
#SP500 | Y | | Operates within the SP500 universe |
#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
2Not available in Ranking Systems