Supertrend
Supertrend in ProBuilder returns an ATR-based trailing stop line that flips above or below price with the trend. Syntax, parameters, formula and examples.
Syntax
Supertrend[multiplier, N]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
multiplier | decimal | 3 | Distance factor applied to the ATR. Larger values place the line further from price, producing fewer but later flips. Smaller values react faster and whipsaw more. |
N | integer | 10 | Lookback period for the Average True Range component. |
Formula
Median = (high + low) / 2
UpperBand = Median + multiplier * AverageTrueRange[N]
LowerBand = Median - multiplier * AverageTrueRange[N]The Supertrend line follows the lower band while price holds above it and the upper band while price holds below it. Each band only ratchets in the trend direction, so the line never moves against the current trend until price closes through it and the indicator switches to the opposite band.
How it works
On every bar, ProBuilder computes an ATR-based envelope around the bar midpoint. While the trend is up, the indicator tracks the rising lower band beneath price, ignoring any downward adjustment of that band. When a close breaks below the line, the indicator flips and starts tracking the upper band above price instead.
The result is a single stepped line that behaves like a trailing stop. Its distance from price expands in volatile conditions and contracts in quiet ones, because the ATR term scales the offset. This makes the same parameter set usable across instruments with different price levels and volatility profiles.
Note that Supertrend takes no price argument. Unlike moving averages such as Average[N](price), the calculation is fixed to the bar's high, low and close values.
Examples
Example 1, Detecting a bullish flip (Indicator)
st = Supertrend[3,10]
// Flag the bar where price closes back above the line
IF(close > st AND close[1] < st[1]) THEN
bullishSignal = 1
ELSE
bullishSignal = 0
ENDIF
RETURN bullishSignalReturns 1 on the exact bar where the close moves from below to above the Supertrend line, and 0 otherwise. This marks the transition from a bearish to a bullish regime.
Example 2, Trend-following entries and exits (ProOrder)
// Long-only system that follows the Supertrend flips
DEFPARAM CumulateOrders = false
st = Supertrend[3, 10]
IF close CROSSES OVER st THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF close CROSSES UNDER st THEN
SELL AT MARKET
ENDIFEnters long when price closes above the line and exits when price closes back below it. The line itself acts as the trailing exit level.
Example 3, Screening for fresh bullish flips (ProScreener)
st = Supertrend[3, 10]
// True only on the bar of the flip itself
flip = close > st AND close[1] <= st[1]
SCREENER[flip]((close - st) AS "Distance above line")Lists instruments whose price flipped above the Supertrend on the current bar, sorted by how far the close sits above the new support line.
Interpretation
| Condition | Reading |
|---|---|
| Close above the line | Uptrend. The line acts as dynamic support and a trailing stop level. |
| Close below the line | Downtrend. The line acts as dynamic resistance. |
| Line flip | Possible trend change. Frequent flips in a tight range indicate a non-trending market. |
Supertrend is a trend-following tool. It performs best in sustained directional moves and produces a series of small losing flips in sideways markets. A separate trend-strength filter such as ADX is often used to suppress signals in ranges.
Common errors and gotchas
- Parameter order. The multiplier comes first and the period second:
Supertrend[3, 10]. Reversing them toSupertrend[10, 3]compiles but produces a very tight, fast line that bears no resemblance to the intended indicator. - No price argument.
Supertrend[3,10](close)is invalid. The function is computed from the bar's high, low and close and accepts only the two bracket parameters. - Whipsaw in ranging markets. Every flip is a signal, and in a sideways market flips cluster. Systems that trade every flip without a range filter accumulate many small losses.
- Intrabar flips. On a live chart the current bar can cross the line and cross back before the bar closes. Signal logic based on
closeonly becomes final when the bar completes.
Related instructions
AverageTrueRange, the volatility measure inside the Supertrend bands.TR, single-bar True Range, the raw input to ATR.SAR, parabolic stop and reverse, another flipping trailing stop.ChandeKrollStopUp, ATR-based stop line above price.ChandeKrollStopDown, ATR-based stop line below price.ADX, trend-strength filter often paired with Supertrend.Average, simple moving average for baseline comparisons.ExponentialAverage, faster moving average alternative.
