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 | Type | Required | Description |
|---|---|---|---|
| supertrend | value | Optional | color theme.accent, color_down theme.down, color_up theme.up, style line, width 1 |
| direction | value | Optional | color theme.accent, style line, width 1 |
- Warm-up
- atr_period - 1 bars (9 at the defaults)
- Repaints
- No
- Parity
- None
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.