# Variable index dynamic average

`vidya`

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 | Kind |
| --- | --- |
| vidya | value |

Warm-up: period_ema + period_cmo - 1 bars (20 at the defaults).

Repaints: No.

## 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.
