SMA(bars [,offset,series]): Simple moving average
EMA(bars [,offset,series]): Exponential moving average
VMA(bars [,offset]): Volume weighted moving average
WMA(bars [,offset,series]): Weighted moving average
These functions calculate moving averages for a time series. When evaluates in the past, future splits are reversed out to return a point-in-time value. Please note that our time series are adjusted for dividends to create smooth trends. The parameters are:
bars: the period of the average (use 2-500)
offset: bar offset from the as-of date (use 0-100, defaults to 0)
series: specify alternate time series.
If the requested number of bars to average is greater than the entire number of bars in the time series then this function will return NA.
Examples
To screen for stocks whose 50 bar simple average is above the 200 bar average enter:
SMA(50) > SMA(200)
To screen for stocks whose 50 bar simple average is above the the 50 bar moving average 10 bars ago enter:
SMA(50) > SMA(50,10)
To only buy stocks when the 50 bar simple moving average of the benchmark is above the 200 bar average, enter the following Buy Rule:
SMA(50,0,#Bench) > SMA(200,0,#Bench)
By default, technical functions access the time series of the instrument in context. You can specify a different time-series in several ways like: using GetSeries(), specifying a StockID directly, or using a time series id. See the examples below.
Examples
Get the latest close price using Close(0, series) using different methods for different time series.
| Using the ID directly | |
| Using the StockID for SPY:USA* | Close(0, 24262) |
| For the Industry series of the stock being evaluated | Close(0,#Industry) |
| Using a Time Series Id | Close(0,$RUI) |
| For the benchmark | Close(0, #Bench) |
| Using GetSeries | |
| Using a fully qualified ticker | Close(0, GetSeries("SPY:USA")) |
| When USA is your default | Close(0, GetSeries("SPY")) |
| See GetSeries() for more examples like for aggregate series | |
| * StockIDs never change | |
Predefined Series IDs
These are special series ids. Additional Series Ids can be found in the reference under: MISC→TIME SERIES IDs
| Id | Description | Freq | OHLC |
| Industry and Sector | |||
| #Sector | Stock's Sector | Daily | C |
| #SubSector | Stock's SubSector | Daily | C |
| #Industry | Stock's Industry | Daily | C |
| #SubIndustry | Stock's SubIndustry | Daily | C |
| Miscellaneous | |||
| #Bench | Benchmark closing prices | Daily | C |
| #TNX | 10Y Treasury Note | Daily | OHLC |
| FED Model series (chart) | |||
| #SPRP | SP500 Risk Premium | Weekly | C |
| #SPEPSCY | SP500 EPS CurrentY | Weekly | C |
| #SPEPSNY | SP500 EPS NextY | Weekly | C |
| #SPEPSCNY | SP500 EPS Blend Y | Weekly | C |
| #SPEPSQ | SP500 EPS Blend Q | Weekly | C |
| #SPEPSTTM | SP500 EPS Trailing 12 months | Weekly | C |
| #SPYield | SP500 Yield | Weekly | C |
Special Series Ids for Moving Averages & Highest/Lowest functions
| Id | Description | Context |
| #Open | Open prices | Stock & ETF |
| #High | High prices | Stock & ETF |
| #Low | Low prices | Stock & ETF |
| #Vol | Volumes | Stock & ETF |