# Supertrend indicator formula

Recently i am working on an indicator called "Supertrend", however i am a hard time to get the right value.

The formula

BASIC UPPERBAND  =  (HIGH + LOW) / 2 + Multiplier * ATR
BASIC LOWERBAND =  (HIGH + LOW) / 2 - Multiplier * ATR

FINAL UPPERBAND = IF((Current BASICUPPERBAND  < Previous FINAL UPPERBAND) and (Previous Close > Previous FINAL UPPERBAND))
THEN Current BASIC UPPERBAND
ELSE Previous FINALUPPERBAND

FINAL LOWERBAND = IF((Current BASIC LOWERBAND  > Previous FINAL LOWERBAND) and (Previous Close < Previous FINAL LOWERBAND))
THEN Current BASIC LOWERBAND
ELSE Previous FINAL LOWERBAND

SUPERTREND = IF(Current Close <= Current FINAL UPPERBAND )
THEN Current FINAL UPPERBAND
ELSE Current  FINAL LOWERBAND


http://www.freebsensetips.com/blog/detail/7/What-is-supertrend-indicator-its-calculation

And i write an excel to calculate manually on Hang Seng Index 1-Day data https://docs.google.com/spreadsheets/d/1Q_TCVa6uV-Go2nX6rsI2_a-jTyZFfGI42R8Wb0_FI-c/edit?usp=sharing

The data source is from investing.com https://www.investing.com/indices/hang-sen-40-historical-data

The supertrend data is correct as long as to row 129(counting from the bottom), but in row 129(30-Jul-19), the supertrend value is starting to be wrong

My questions on this

1) I see two different calculations on ATR, one using ATR(t-1) * 13 + ATR(t) / 10, and the other one is using simple average of last 10

When using the simple average, the supertrend value of the bottom rows(144-130) works out as the same as investing.com's graph, but the ATR is not the same as investing.com.

However, when switching back ATR calculation to ATR(t-1) * 13 + ATR(t) / 10, the ATR value align with investing.com's data, but the supertrend data is wrong.

Looking forward to have a clear clarification on supertrend formula and how to calculate it manually and accurately(same as the value as investing.com, no matter what ATR you use, but please just specified)

• There are two different definitions of ATR. One uses the simple average of TR (which is what I am used to), but the other one, which apparently was the original definition, uses an exponential moving average of ATR. If you google you can see different people using these 2 different ADRs. – Alex C Aug 20 at 23:20
• @AlexC ya i have noticed that and edited my question to look for the right way to calculate Supertrend value, do you have any ideas? – Edison Lo Aug 21 at 15:49