VWAP is getting populated correct untill the second last candle, on the last candle it takes the candle’s value.. need it to maintain the gap similar to previous candle
can’t seem top figure out what is going wrong
The Code :
//@version=5
indicator('VWAP', shorttitle='VWAP', overlay=true)
// Inputs for displaying VWAPs
sd = input(true, title='Show Daily VWAP?')
startd = request.security(syminfo.tickerid, 'D', time)
change_1 = ta.change(startd)
newSessiond = change_1 ? 1 : 0
var float vwapsumd = na
var float volumesumd = na
vwapsumd := newSessiond ? hl2 * volume : nz(vwapsumd[1]) + hl2 * volume
volumesumd := newSessiond ? volume : nz(volumesumd[1]) + volume
myvwapd = vwapsumd / volumesumd
plot(sd and myvwapd ? myvwapd : na, title='VWAP_DAILY', color=color.new(color.green, 0))
New contributor
vatsal bindal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.