Navigation: Realtest Script Language > Syntax Element Details >

XAvg or EMA

 

 

 

 

Category

Multi-Bar Functions

Description

Exponential Moving Average

Syntax

XAvg(expr, count) or EMA(expr, count)

Parameters

expr - data series formula

count - lookback period

Notes

Either XAvg or EMA can be used as the name of this function.

Count is usually thought of as an integer representing a number of bars, but can actually be any decimal value. An EMA is constructed by multiplying each difference between the result so far and the next value by a factor equal to 2.0 / (count + 1.0).

To calculate an EMA of count length with full precision, at least 5*count bars are required. RealTest calculates all exponential functions using however many bars are available, but if you require full precision, you will need to start your backtests that many bars after the start of your data file.

Note that, like most other backtesting software, RealTest begins each EMA calculation with MA(expr, count), then begins to apply the EMA weighting for subsequent bars once count has been reached.

This function supports ultra-fast one-pass calculation when used in the Data Section with a non-variable count.

 

 

 

 

Copyright © 2020-2022 Systematic Solutions, LLC