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?