Standard Definition
The standard definition would be an expression of the form
which can be expressed as the update rule
If and
, then
To ensure the EMA is asymptotically unbiased with constant price, choose and define the update rule as
Implementation
Using a floating-point implementation,
double alpha;double ema = 0.0;ema = p + alpha * (ema - p);
This approach may not be suitable for high-frequency applications, due to jitter. Instead fixed point integer arithmetic might be used.
