Hello ProBuilder Community,
I’ve noticed a slight difference between the VWAP (Volume-Weighted Average Price) indicator on TradingView and the one on ProRealTime. On some charts, the ProRealTime VWAP appears to be offset by about five candles compared to TradingView’s, especially around gaps.
Has anyone else encountered this? If so, is there a way to adjust the ProRealTime VWAP calculation (or code a custom version) to match TradingView’s implementation more closely?
I’d greatly appreciate any insights or suggestions. Thank you in advance for your help.
Pinescript code:
//@version=6
indicator(title=”Manual Session VWAP”, shorttitle=”VWAP”, overlay=true)
// Fixed source and session anchor
src = hlc3
// Detect new daily session
isNewSession = timeframe.change(“D”)
// Cumulative sums reset each session
var float cumPV = na
var float cumVol = na
cumPV := isNewSession ? src * volume : nz(cumPV[1]) + src * volume
cumVol := isNewSession ? volume : nz(cumVol[1]) + volume
vwapValue = cumPV / cumVol
// Plot VWAP in blue
plot(vwapValue, title = “VWAP”, color = #2962FF)
Probulder code:
// PRC_VWAP intraday (VWAP only, HLC3 version)
// SAME LOGIC, explicit HLC3 instead of typicalprice
// 09.01.2020
// Nicolas @
http://www.prorealcode.com
// Modified: explicit HLC3if day <> day[1] then
d = 0
else
d = d + 1
hlc3 = (high + low + close) / 3
if volume > 0 then
VWAP = summation[d](volume * hlc3) / summation[d](volume)
endif
endif
if VWAP > VWAP[1] then
color = 1
else
color = -1
endif
RETURN VWAP COLOURED BY color STYLE(LINE, 2) AS “VWAP”