# Simple moving average

`sma`

Average of the last N values, each weighted equally.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| source | source | close |  |
| period | int | 20 | 1 to 5000 |

## Outputs

| Name | Kind |
| --- | --- |
| sma | value |

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

Repaints: No.

## Formula

SMA[i] = (x[i] + x[i-1] + ... + x[i-period+1]) / period

No value until period bars exist. A window holding a missing value has no value.
