# Rolling median

`median`

Middle value of the last N values, so one spike cannot move it.

## Inputs

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

## Outputs

| Name | Kind |
| --- | --- |
| median | value |

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

Repaints: No.

## Formula

Median[i] = the middle of the sorted values x[i-period+1] to x[i]

With an even period it is the mean of the two middle values. A window holding a missing value has no value.
