# Fractal adaptive moving average

`frama`

Average that follows trends closely and flattens in chop, from the fractal dimension.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| period | int | 14 | 1 to 5000 |

## Outputs

| Name | Kind |
| --- | --- |
| frama | value |

Warm-up: 2 * period - 1 bars (27 at the defaults).

Repaints: No.

## Formula

N1 = (highest high - lowest low over the last period bars) / period

N2 = the same over the period bars before those, N3 = the same over all 2 * period bars divided by 2 * period

D = (ln(N1 + N2) - ln(N3)) / ln(2), alpha = exp(-4.6 * (D - 1))

FRAMA[i] = alpha * close[i] + (1 - alpha) * FRAMA[i-1]

The first 2 * period - 1 values are left empty.
