# SuperTrend

`supertrend`

Trend-following line built from the average true range.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| atr_period | int | 10 | 1 to 500 |
| factor | float | 3 | 0.1 to 20 |

## Outputs

| Name | Kind |
| --- | --- |
| supertrend | value |
| direction | value |

Warm-up: atr_period - 1 bars (9 at the defaults).

Repaints: No.

## Formula

upper = (high + low) / 2 + factor * ATR, lower = (high + low) / 2 - factor * ATR

Each band only moves toward price, unless the previous close crossed it.

The line is the lower band while the trend is up and the upper band while it is down. direction is 1 up and -1 down. ATR is Wilder's average true range.
