ema
Exponential Moving Average
ema(source, periods)
Parameters
| Name | Type | Description |
|---|---|---|
source |
field | Data series |
periods |
int | Number of periods |
Formula
EMA = (value * multiplier) + (prev_EMA * (1 - multiplier)), multiplier = 2 / (periods + 1)
Examples
// price above 8-day EMA (short-term uptrend)
close > ema(close, 8);
// price below 21-day EMA (intermediate downtrend)
close < ema(close, 21);
// fast EMA crossed above slow EMA (golden cross)
crossover(ema(close, 12), ema(close, 26));
// price above 200-day EMA (long-term uptrend)
close > ema(close, 200);
Returns
float — may be NULL
Range
periods must be 2-210
Notes
Seeded with the SMA over the periods bars ending at the seed bar; the recursion starts there. No value before the seed bar (periods-1 rows past the source's own warm-up are NULL)