Variable index dynamic average
Exponential average that speeds up when momentum is strong.
Inputs
| Name | Type | Default | Range |
|---|---|---|---|
| source | source | close | |
| period_cmo | int | 9 | 1 to 5000 |
| period_ema | int | 12 | 1 to 5000 |
Outputs
| Name | Type | Required | Description |
|---|---|---|---|
| vidya | value | Optional | color theme.accent, style line, width 1 |
- Warm-up
- period_ema + period_cmo - 1 bars (20 at the defaults)
- Repaints
- No
- Parity
- MetaTrader 5, within 1e-12
Formula
CMO = (sum of up moves - sum of down moves) / (sum of up moves + sum of down moves) over period_cmo bars
alpha = 2 / (period_ema + 1) * |CMO|
VIDYA[i] = x[i] * alpha + VIDYA[i-1] * (1 - alpha)
After a gap the average starts again.