# Arnaud Legoux moving average

`alma`

Gaussian weighted average whose peak you can move toward the newest bar.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| source | source | close |  |
| window | int | 9 | 1 to 5000 |
| offset | float | 0.85 | 0 to 1 |
| sigma | float | 6 | 0.5 to 50 |

## Outputs

| Name | Kind |
| --- | --- |
| alma | value |

Warm-up: window - 1 bars (8 at the defaults).

Repaints: No.

## Formula

m = offset * (window - 1), s = window / sigma

w[k] = exp(-(k - m)^2 / (2 * s^2)), k = 0 for the oldest bar of the window

ALMA[i] = sum(w[k] * x[i-window+1+k]) / sum(w[k])
