# Exponential moving average

`ema`

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

Warm-up: period - 1 bars (13 at the defaults).

Repaints: No.

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