MyAlgoMate
// INDICATOR FORMULA

Supertrend formula: how to calculate Supertrend (with Excel)

How the Supertrend line is worked out — ATR bands around each candle's midpoint and the rules that move the line from one band to the other. With a worked example (settings 10, 3), the Excel formulas, a free Excel sheet and a box to calculate Supertrend from your own prices.

Last updated:

Download the free Supertrend Excel sheet (.xlsx)

Needs: high, low, close · Standard settings: ATR period 10 · Multiplier 3

The Supertrend formula

ATR = ATR (10), Wilder's smoothing

Basic upper = (High + Low) ÷ 2 + 3 × ATR
Basic lower = (High + Low) ÷ 2 − 3 × ATR

Final upper = Basic upper, if Basic upper < previous Final upper
                           or previous Close > previous Final upper
              otherwise previous Final upper
Final lower = Basic lower, if Basic lower > previous Final lower
                           or previous Close < previous Final lower
              otherwise previous Final lower

Supertrend: if yesterday it was on the upper band →
                today = Final lower if Close > Final upper, else Final upper
            if yesterday it was on the lower band →
                today = Final upper if Close < Final lower, else Final lower

10 is the ATR period and 3 the multiplier. On the very first candle there is no “yesterday”, so the line starts on the upper band. The ATR is worked out exactly as on the ATR formula page.

How to calculate Supertrend step by step

  1. Work out the true range and the 10-period ATR. The first ATR, on Day 10, is the average of the first 10 true ranges: 20.80.
  2. Build the basic bands around the candle's midpoint. Day 10: (1,046.15 + 1,028.50) ÷ 2 ± 3 × 20.80 gives a basic upper band of 1,099.73 and a basic lower band of 974.92. Day 10 is the first candle with an ATR, so its final bands equal its basic bands, and the Supertrend starts on the upper band: 1,099.73.
  3. Apply the final-band rule. Day 11's basic upper band (1,095.14) is lower than the previous final upper (1,099.73), so the final upper band moves down to 1,095.14. Its basic lower band (974.36) is not higher than the previous final lower (974.92) and the previous close didn't go below it, so the final lower band stays at 974.92.
  4. Check the close against the band the line is on. The line stays on the upper band until Day 43, when the close (919.00) goes above the final upper band (912.13). From then the Supertrend is the final lower band: 844.74, and the Trend column changes from “Down” to “Up”.
  5. Repeat for every candle. On Day 60 the example's Supertrend is 942.08, on the lower band.

Worked example — and calculate Supertrend from your own prices

The table works through 60 daily candles of an imaginary stock, column by column — the same columns as the Excel sheet. To calculate Supertrend for your own stock, clear the box and paste your high, low, close from Excel or your broker's download.

One row per candle, oldest first. Paste straight from Excel or your broker's download; a date or time column becomes the row label. Filled with our example prices.

Latest values

Supertrend: 942.0761Trend: Up
Supertrend calculated from the example prices
DayHighLowCloseTrue rangeATR (10)Basic upperBasic lowerFinal upperFinal lowerSupertrendTrend
Day 11,010.00990.601,001.1519.40
Day 21,004.60987.75987.9516.85
Day 31,011.50986.001,009.1525.50
Day 41,015.001,001.851,012.6013.15
Day 51,012.00990.80993.2521.80
Day 61,012.60990.901,008.6021.70
Day 71,018.951,003.801,013.6015.15
Day 81,012.95994.751,001.5518.85
Day 91,033.25995.301,031.5537.95
Day 101,046.151,028.501,040.0517.6520.80001,099.7250974.92501,099.7250974.92501,099.7250Down
Day 111,041.801,027.701,033.1514.1020.13001,095.1400974.36001,095.1400974.92501,095.1400Down
Day 121,065.801,031.151,064.8034.6521.58201,113.2210983.72901,095.1400983.72901,095.1400Down
Day 131,086.001,056.851,083.5529.1522.33881,138.44141,004.40861,095.14001,004.40861,095.1400Down
Day 141,090.251,067.251,067.9523.0022.40491,145.96481,011.53521,095.14001,011.53521,095.1400Down
Day 151,074.301,061.451,063.5012.8521.44941,132.22331,003.52671,095.14001,011.53521,095.1400Down
Day 161,067.351,025.901,030.2041.4523.44951,116.9735976.27651,095.14001,011.53521,095.1400Down
Day 171,033.001,011.751,012.2021.2523.22951,092.0636952.68641,092.06361,011.53521,092.0636Down
Day 181,019.90979.85981.6040.0524.91161,074.6097925.14031,074.60971,011.53521,074.6097Down
Day 19988.30969.40970.5518.9024.31041,051.7813905.91871,051.7813905.91871,051.7813Down
Day 20973.10959.05960.9014.0523.28441,035.9281896.22191,035.9281905.91871,035.9281Down
Day 21980.35958.30978.3022.0523.16091,038.8078899.84221,035.9281905.91871,035.9281Down
Day 22981.50957.00958.8524.5023.29481,039.1345899.36551,035.9281905.91871,035.9281Down
Day 23963.00942.60946.7520.4023.00541,021.8161883.78391,021.8161905.91871,021.8161Down
Day 24957.70931.65937.9526.0523.30981,014.6045874.74551,014.6045905.91871,014.6045Down
Day 25945.75926.05927.8519.7022.94881,004.7465867.05351,004.7465905.91871,004.7465Down
Day 26924.60910.25911.2017.6022.4140984.6669850.1831984.6669905.9187984.6669Down
Day 27919.05900.00905.1519.0522.0776975.7577843.2923975.7577905.9187975.7577Down
Day 28904.50884.70885.9520.4521.9148960.3444828.8556960.3444828.8556960.3444Down
Day 29891.25871.55874.7019.7021.6933946.4800816.3200946.4800828.8556946.4800Down
Day 30880.70849.70855.8031.0022.6240933.0720797.3280933.0720828.8556933.0720Down
Day 31868.95858.15862.1513.1521.6766928.5798798.5202928.5798828.8556928.5798Down
Day 32875.05859.50866.4515.5521.0639930.4668804.0832928.5798828.8556928.5798Down
Day 33870.55843.00845.1027.5521.7125921.9126791.6374921.9126828.8556921.9126Down
Day 34854.70846.55851.559.6020.5013912.1289789.1211912.1289828.8556912.1289Down
Day 35863.70847.85860.2015.8520.0362915.8835795.6665912.1289828.8556912.1289Down
Day 36862.95845.40854.8017.5519.7875913.5376794.8124912.1289828.8556912.1289Down
Day 37882.25858.05877.2027.4520.5538931.8114808.4886912.1289828.8556912.1289Down
Day 38893.65868.85888.4524.8020.9784944.1852818.3148912.1289828.8556912.1289Down
Day 39908.35889.60905.4019.9020.8706961.5867836.3633912.1289836.3633912.1289Down
Day 40913.10895.65896.8017.4520.5285965.9605842.7895912.1289842.7895912.1289Down
Day 41894.65887.85889.608.9519.3707949.3620833.1380912.1289842.7895912.1289Down
Day 42898.55884.80895.3013.7518.8086948.1008835.2492912.1289842.7895912.1289Down
Day 43920.60889.25919.0031.3520.0627965.1132844.7368912.1289844.7368844.7368Up
Day 44920.60916.30918.354.3018.4865973.9094862.9906973.9094862.9906862.9906Up
Day 45919.30903.80906.2515.5018.1878966.1134856.9866966.1134862.9906862.9906Up
Day 46937.35900.30932.1037.0520.0740979.0471858.6029966.1134862.9906862.9906Up
Day 47947.15930.20944.3516.9519.7616997.9599879.3901966.1134879.3901879.3901Up
Day 48949.20937.25948.7011.9518.98051,000.1664886.2836966.1134886.2836886.2836Up
Day 49971.15949.05966.3522.4519.32741,018.0823902.1177966.1134902.1177902.1177Up
Day 50965.90954.75955.6011.6018.55471,015.9890904.66101,015.9890904.6610904.6610Up
Day 51971.35954.15969.1017.2018.41921,018.0076907.49241,015.9890907.4924907.4924Up
Day 52997.00966.55984.3530.4519.62231,040.6419922.90811,015.9890922.9081922.9081Up
Day 53992.30980.25980.9012.0518.86511,042.8702929.67981,015.9890929.6798929.6798Up
Day 54984.70961.40962.5023.3019.30861,030.9757915.12431,015.9890929.6798929.6798Up
Day 55964.60953.00960.2011.6018.53771,014.4131903.18691,014.4131929.6798929.6798Up
Day 56969.05954.50967.3514.5518.13891,016.1918907.35821,014.4131929.6798929.6798Up
Day 57982.20960.60971.0021.6018.48501,026.8551915.94491,014.4131929.6798929.6798Up
Day 58987.10967.55981.7519.5518.59151,033.0996921.55041,014.4131929.6798929.6798Up
Day 59999.95979.00994.8520.9518.82741,045.9571932.99291,014.4131932.9929932.9929Up
Day 601,015.15987.351,012.3527.8019.72461,060.4239942.07611,014.4131942.0761942.0761Up
Everything is worked out in your browser. Nothing you paste is stored or sent.

The example prices are made up for this page — they are not real market data. Supertrend is a calculation from past prices, not a forecast, a signal or advice to buy or sell. MyAlgoMate provides trading technology, not investment advice.

How to calculate Supertrend in Excel

Put the headings in row 1 and the first candle in row 2, oldest at the top. Then type these formulas — each column uses the ones to its left:

  1. A

    Day

    A2 downwards: your dates, oldest at the top.

  2. B

    High

    B2 downwards: the high prices, oldest at the top.

  3. C

    Low

    C2 downwards: the low prices, oldest at the top.

  4. D

    Close

    D2 downwards: the closing prices, oldest at the top.

  5. E

    True range

    E2 =B2-C2 — this cell only (the starting value).

    E3 =MAX(B3-C3,ABS(B3-D2),ABS(C3-D2)) — then copy it down to the last row.

  6. F

    ATR (10)

    F11 =AVERAGE(E2:E11) — this cell only (the starting value).

    F12 =(F11*9+E12)/10 — then copy it down to the last row.

  7. G

    Basic upper

    G11 =(B11+C11)/2+3*F11 — then copy it down to the last row.

  8. H

    Basic lower

    H11 =(B11+C11)/2-3*F11 — then copy it down to the last row.

  9. I

    Final upper

    I11 =G11 — this cell only (the starting value).

    I12 =IF(OR(G12<I11,D11>I11),G12,I11) — then copy it down to the last row.

  10. J

    Final lower

    J11 =H11 — this cell only (the starting value).

    J12 =IF(OR(H12>J11,D11<J11),H12,J11) — then copy it down to the last row.

  11. K

    Supertrend

    K11 =I11 — this cell only (the starting value).

    K12 =IF(K11=I11,IF(D12>I12,J12,I12),IF(D12<J12,I12,J12)) — then copy it down to the last row.

  12. L

    Trend

    L11 =IF(K11=J11,"Up","Down") — then copy it down to the last row.

In the sheet, “Up” means the line is on the final lower band (below the candles) and “Down” that it is on the final upper band (above them). The labels only describe which band is in use.

Prefer not to type them? The free sheet has every formula filled in for the example prices — replace the prices with yours and extend the rows. It opens in Microsoft Excel (we checked every value against the table above), and you can import it into Google Sheets or LibreOffice.

Download the free Supertrend Excel sheet (.xlsx)

What is the Supertrend indicator?

Supertrend is a line drawn on a price chart. It is built from the Average True Range (ATR), a measure of how far price usually moves in one candle. The line sits on one side of the candles and switches to the other side when a candle closes through it. It was developed by Olivier Seban in the early 2000s, and its common defaults are an ATR period of 10 and a multiplier of 3 (see the cTrader help page). It is a calculation from past prices. It does not forecast anything.

What the two settings change

What the ATR period and the multiplier change
SettingWhat it changes
ATR period (default 10)How many candles are used to measure the usual range. A smaller number reacts to new candles faster.
Multiplier (default 3)How many ATRs the bands sit from the midpoint. A bigger number puts the line further from price.
Maths check: midpoint 100, ATR 4Multiplier 2 gives bands 108 / 92. Multiplier 3 gives bands 112 / 88.

The same candles with different settings give a different line.

How often the line switched in the example

In the 60 example candles (settings 10, 3) the line changed bands 1 time: Day 43 (to the lower band). Counted straight from the Trend column of the example table above.

Where Supertrend has limits

Like any line built from past prices, it lags. When price moves sideways, the line can switch sides several times, because each switch needs only one close through the band. This is a property of the maths, not a comment on any result.

Supertrend and other lines

Supertrend compared with a moving average and Parabolic SAR
LineHow it is built
Moving averageThe average of closing prices. No ATR.
SupertrendThe high-low midpoint plus or minus a multiple of the ATR, with one band shown at a time.
Parabolic SARA different formula that also trails price.

What the Supertrend line shows

The line follows one band at a time: the upper band above the candles or the lower band below them. It changes sides only when a candle closes beyond the band it is on. That is all the formula does — it is a calculation from past prices, not a forecast and not advice, and how you use it is your own decision.

Why your Supertrend may not match your chart

  • The ATR method. Wilder's smoothing (this page and most charts) vs a simple average of the true range.
  • The starting point. The bands carry forward from the first candle, so start from plenty of history — the difference fades.
  • Settings and prices. ATR period, multiplier, spot vs futures, timeframe.
// FAQ

Supertrend calculation — questions, answered.

Work out the ATR (10). Basic upper band = (High + Low) ÷ 2 + 3 × ATR; basic lower band = (High + Low) ÷ 2 − 3 × ATR. The final upper band may only move down and the final lower band may only move up, unless the previous close crossed them. The Supertrend line sits on the final upper band until a close goes above it, then on the final lower band until a close goes below it.

Put high, low and close in columns B, C and D. Add true range and a 10-period ATR (Wilder's smoothing), then the basic bands, then the final bands with IF and OR, and finally the Supertrend column, which checks which band yesterday's value was on. The column-by-column formulas are on this page, and the free sheet has all of them filled in.

The first number is the ATR period and the second is the multiplier. 10, 3 means a 10-period ATR with the bands 3 ATRs from the candle's midpoint; 7, 3 uses a 7-period ATR with the same multiplier. A bigger multiplier puts the bands further away. You can enter any settings in the calculator above.

Because of the final-band rule. The upper band is only allowed to come down (and the lower band only to go up) while price stays on the same side, so when the new basic band would move the other way, the final band simply repeats yesterday's value.

Both. The bands are built around the midpoint of each candle's high and low, while the switch from one band to the other is decided by the close.

Check the ATR: most charts use Wilder's smoothing, but some versions use a simple average of the true range. The starting point matters too — Supertrend carries its bands forward from the first candle, so use plenty of history. Spot vs futures prices and the timeframe also change it.

The formula uses only the high, low and close of each candle. On a finished candle the value does not change. On a candle that is still forming, the close is not final yet, so the value can change until that candle closes.

Any. The formula works on whatever candles you give it, and the ATR is measured in those candles. A different timeframe means different candles, so the values are different too.

A moving average averages closing prices. Supertrend uses the midpoint of each candle's high and low plus or minus a multiple of the ATR, and it shows one band at a time.

More indicator formulas, with Excel sheets

Turn your own rules into automated orders.

Already use Supertrend in your own rules? MyAlgoMate's algo trading software places the orders your rules call for at 150+ Indian brokers — and TradeBridge turns your own TradingView or Chartink alerts into live orders. You decide the rules; we provide the technology.

Share this page