Reputation: 712
I wonder how the price increase/decrease in being calculated on TradingView? We have open and close price but the price difference (left arrow) seems not to be correct neither is percentage (right arrow)
difference = open - close
which results in -0.0009 but TradingView calculates -0.0005
Also percentage seems to be different:
difference = ((open - close) / open) * 100
Which results in -0.39% but TradingView shows -0.22%
How TradingView is calculating the price difference?
Upvotes: 0
Views: 533
Reputation: 21139
What you are seeing is change. You should compare the previous close
with the current price
.
//@version=5
indicator("My script")
price_change = close - close[1]
per_change = (close-close[1]) / close[1] * 100
plot(price_change, color=color.blue)
plot(per_change, color=color.white)
plot(close - open, color=color.red) // This is how you do it which is not how Tradingview calculates it
Upvotes: 1