How is Supertrend Calculated? Formula, Parameters, and Data Requirements

Supertrend calculation formula parameters data limitations.

What is Supertrend, and what does it calculate?

Supertrend is a trend-following indicator that transforms price data into a single line (often plotted as a step-like line) and a direction (uptrend or downtrend). It is designed to stay on one side of price until the indicator’s bands are crossed, at which point it switches direction.

At a high level, Supertrend needs three ingredients:

  1. A price series (for example, using each bar’s high/low/close).
  2. A volatility estimate (typically ATR, average true range).
  3. A rule that turns volatility-adjusted bands into a maintained trend line.

Because it relies on moving-window calculations (ATR, and optionally smoothing), the exact numeric output depends on how you compute ATR, which “bar” definition you use (timeframe and OHLC data), and the parameters you choose.

The core mechanics: bands, ATR, and the trend switch

Supertrend is calculated iteratively for each new bar. The most common formulation uses:

Step 1: Compute the True Range (TR)

For each bar t, define True Range using high/low/close. A standard definition is:

  • (TR_t = \max{H_t - L_t,\ |H_t - C_{t-1}|,\ |L_t - C_{t-1}|})

Where:

  • (H_t) = high of bar t
  • (L_t) = low of bar t
  • (C_t) = close of bar t
  • (C_{t-1}) = previous bar’s close

Step 2: Compute ATR (Average True Range)

ATR is an average of TR over a chosen period (n). A common choice is a simple moving average (SMA):

  • (ATR_t = \text{SMA}(TR_t, n))

Some implementations instead use Wilder’s smoothing (which is common for ATR), but the key point for verification is: you must match the smoothing method used by your reference implementation.

Step 3: Compute the basic upper and lower bands

A typical Supertrend band construction uses the mid-price (M_t) and ATR multiplied by a factor (k) (the multiplier):

  • (M_t = (H_t + L_t) / 2)
  • (\text{BasicUpper}_t = M_t + k \cdot ATR_t)
  • (\text{BasicLower}_t = M_t - k \cdot ATR_t)

Parameters you need:

  • (n): ATR lookback length (often called “period”).
  • (k): ATR multiplier (often called “multiplier”).

Step 4: Apply “band finalization” rules (carry-forward logic)

Supertrend typically adjusts (finalizes) bands so they do not move against the current trend. One widely used rule set is:

  • (\text{FinalUpper}_t) is usually set to (\text{BasicUpper}_t) unless conditions suggest it should be carried forward from the prior bar.
  • (\text{FinalLower}_t) is usually set to (\text{BasicLower}_t) unless conditions suggest it should be carried forward from the prior bar.

A common conditional structure is based on the previous close and the previously finalized band values. Conceptually:

  • When price is above the prior trend line, the lower band can “ratchet” upward but should not decrease.
  • When price is below the prior trend line, the upper band can “ratchet” downward but should not increase.

Because implementations differ, this is an important data requirement: to reproduce a specific Supertrend series, you must use the same band-finalization rule as your reference.

Step 5: Determine trend direction and the Supertrend line

Once final upper/lower bands exist, Supertrend chooses the trend direction by comparing current price (often close) to the relevant band:

  • If the indicator is in an uptrend state and price crosses below the final lower/upper boundary (depending on the convention), it flips to downtrend.
  • If in downtrend and price crosses above the other boundary, it flips to uptrend.

The Supertrend “line” for bar t is then set to:

  • the final lower band when the state is uptrend (or the final upper band when in downtrend), following the indicator’s plotting convention.

This iterative state machine is why Supertrend is not just a single formula: the output depends on prior bars’ finalized bands and prior trend state.

Example calculation (with explicit assumptions)

Below is a verification-style mini-example that shows what you would compute, not the exact numeric result.

Assumptions for the example:

  • You use bars with known (H_t, L_t, C_t).
  • You compute (TR_t) with the max definition.
  • You compute ATR as SMA over (n) bars.
  • You use parameters (n) and (k) chosen by the calculator you are reproducing.
  • You use a standard band-finalization rule consistent with the implementation you want to match.

Procedure:

  1. For bars starting at (t = 2) (because (C_{t-1}) is needed), compute (TR_t).
  2. For each bar (t) where enough TR values exist ((t \ge n) in an SMA sense), compute (ATR_t).
  3. Compute (M_t = (H_t + L_t)/2).
  4. Compute basic bands:\
    • (\text{BasicUpper}_t = M_t + k\cdot ATR_t)\
    • (\text{BasicLower}_t = M_t - k\cdot ATR_t)
  5. Apply the implementation’s band-finalization (ratcheting) rules to get (\text{FinalUpper}_t) and (\text{FinalLower}_t).
  6. Update trend state:
    • Compare price to the relevant finalized band according to the indicator’s convention.
    • Output the Supertrend value as the finalized lower (uptrend) or finalized upper (downtrend) band.

What matters for correctness:

  • If your computed series differs, the mismatch is usually caused by ATR smoothing type (SMA vs Wilder), band-finalization rule differences, or how the initial state is set.

What data you need to calculate Supertrend yourself

To reproduce Supertrend independently, you need:

  • A time-ordered OHLC dataset for the instrument you are analyzing (at the exact timeframe used by the calculation).
  • A definition of TR and ATR smoothing (SMA vs Wilder’s smoothing).
  • The parameter values (n) (ATR period) and (k) (multiplier).
  • The band-finalization rules and trend-state update rule used by your chosen definition.

Without the same choices, two calculators can both claim to compute “Supertrend” yet produce different lines.

Material limitations and failure modes

Supertrend is mechanical, but it is not immune to problems. Key limitations include:

  1. Parameter sensitivity Changing (n) or (k) changes how wide the bands are and how quickly volatility changes propagate into the indicator. A setting that stays smooth in one market regime can flip more often in another.

  2. Noisy flips in sideways or choppy conditions When price oscillates around the bands, the trend state can switch frequently. That creates a pattern of alternating up/down phases that may not reflect a sustained trend.

  3. Initialization effects ATR and moving averages require a start-up period. The first computable ATR values (and the initial trend state) influence subsequent finalized bands and state evolution, so early bars can look different across implementations.

  4. Data granularity and OHLC conventions Different bar constructions (timeframe, data source handling of highs/lows, missing bars) can change (TR_t) and thus ATR, shifting band placement.

Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.