Tool
Supertrend
market.supertrend
Inputs
No typed inputs.
Outputs
A bundle: supertrend (the trailing stop price level) and direction (+1 up, -1 down).
Supertrend is a trailing stop drawn from volatility: a line that hugs price from below in uptrends and from above in downtrends, flipping sides when price closes through it. It answers two questions at once - which way is the trend, and where is the stop.
How it works
Two basic bands are drawn at hl2 +/- multiplier x ATR(period). The running upper band may only move down, the lower band only up (each resets when price closes beyond the previous band), which makes the active band a ratchet. While price holds above the lower band the tool reports direction +1 and the line sits below price; a close through the line flips it to the other band and direction to -1.
Configuration
ATR length that sets how much room the bands get (classic 10).
How many ATRs of distance the bands keep from hl2 (classic 3.0). Bigger = fewer, later flips.
Connects to
Examples
- Regime gate: only allow long entries while direction is +1.
- Stop placement: wire supertrend (via math.last) into an ORDER_EXIT stop-loss so the stop trails the trend.
Common mistakes
- In sideways chop the line flips constantly - Supertrend is a trend tool, pair it with a range filter.
- The line is causal but the flip confirms on close; intrabar touches that recover do not flip it.