Exponential moving average
Average that weights recent values more, each step closing part of the gap to the price.
Inputs
| Name | Type | Default | Range |
|---|---|---|---|
| source | source | close | |
| period | int | 14 | 1 to 5000 |
Outputs
| Name | Type | Required | Description |
|---|---|---|---|
| ema | value | Optional | color theme.accent, style line, width 1 |
- Warm-up
- period - 1 bars (13 at the defaults)
- Repaints
- No
- Parity
- MetaTrader 5, within 1e-12
Formula
k = 2 / (period + 1)
EMA[i] = x[i] * k + EMA[i-1] * (1 - k), starting from the first price.
The first period - 1 values are left empty. After a gap the average starts again.