# Kaufman adaptive moving average

`kama`

Average that speeds up when the price trends and slows down when it chops.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| source | source | close |  |
| period | int | 10 | 1 to 5000 |
| fast_period | int | 2 | 1 to 5000 |
| slow_period | int | 30 | 1 to 5000 |

## Outputs

| Name | Kind |
| --- | --- |
| kama | value |

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

Repaints: No.

## Formula

sc = (ER * (fast_sc - slow_sc) + slow_sc)^2, with fast_sc = 2 / (fast_period + 1) and slow_sc = 2 / (slow_period + 1)

KAMA[i] = KAMA[i-1] + sc * (x[i] - KAMA[i-1]), seeded with x[period-1]

The first period values are left empty. After a gap the average starts again.
