Skip to content
All library documents

Supertrend Calculation and Why Implementations May Differ

Article Quant Q&A · Author: M14

Summary

The document presents a proposed Supertrend formula using the midpoint of the high and low prices, the Average True Range, and a multiplier. It selects the upper or lower band according to whether the close is above or below the midpoint. Two charting-software examples are provided, along with the author’s calculations, which do not match the displayed indicator values.

This is a troubleshooting question rather than a verified implementation guide: it gives no accepted answer or evidence identifying the cause of the discrepancy. The examples show that the stated one-period formula alone may not reproduce a charting platform’s output. Supertrend implementations can depend on details such as how ATR is smoothed, how bands carry forward between bars, and how trend direction switches; these details are not specified in the document. The supplied values and formula are useful for framing a check, but they do not establish which convention the charting software uses.

Key ideas

  • The proposed Supertrend bands use the high-low midpoint adjusted by a multiple of ATR.
  • The displayed examples do not match the author’s direct calculations from that formula.
  • ATR smoothing and rules for carrying bands across bars can affect indicator values.
  • The document does not establish the platform’s precise calculation convention.

Tags

Full text
# Supertrend Indicator


# Supertrend Indicator












I'm trying to implement the Supertrend indicator. Unfortunately, I can't calculate the values ​​that my chart software generates. At the moment, I don't fully understand my problem.

You can add the Average True Range and Supertrend indicators here and look at the stock prices, but the values ​​don't add up (Chart ).

The formula to calculate the Supertrend should be:

if Close > (H + L) / 2:

(H + L) / 2 + M * ATR

else:

(H + L) / 2 - M * ATR

For example values to calculate the supertrend provided by the charting software would be:

| Date | Open | High | Low | Close | Supertrend | ATR |
| 01.05.22 | 13996.82 | 14589.45 | 13380.67 | 14388.35 | 13834.08 | 1226.26 |
| 01.06.22 | 14478.37 | 14709.38 | 12618.68 | 12783.77 | 16180.90 | 1312.71 |

With the formula I would calculate 16437.58 (instead of 13834.08) and 11038.61 (instead of 16180.90). Can anyone help?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.