ta.ewm
Smooth a series with an explicit decay factor instead of a window length.
ta.ewm(source, alpha)Exponentially weighted mean with an explicit alpha: y = alpha*source + (1 - alpha)*y[1], seeded with the first observation rather than a window average, so it has a value from the first bar. ta.ema(source, n) is this with alpha = 2/(n+1) and a full-window seed. Use this one when the decay, not the window, is what you know.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
alpha | Constant | number | 0.2 | 0.000001 to 1 | The smoothing factor: 1 is no smoothing at all, near 0 is very heavy. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- 1 bar.
- Missing values
- na until the first non-na observation, which seeds the recurrence. An na resets it, and the next non-na observation seeds it again.
Example
ta.ewm(close, 0.2)plot(ta.ewm(close, 0.2), "Decay 0.2")