Hey everyone,
I am trying to calculate the US session vwap. I want the calculation to start when the US session starts, i.e. 16:30 in Greece. I am using this code but I am not geting the right result:
if OpenTime=163000 then
OpenBarIndex=intradaybarindex
SumVol=0
SumVol2=0
for i=OpenBarIndex to intradaybarindex do
SumVol=volume+SumVol
SumVol2=volume*typicalprice+SumVol2
next
VWAP2 = SumVol2/SumVol
endif
return vwap2
Can you help me fix this code please?
John
Try this version:
if OpenTime=163000 then
SumVol=0
SumVol2=0
Endig
SumVol=volume+SumVol
SumVol2=volume*typicalprice+SumVol2
VWAP2 = SumVol2/SumVol
return vwap2
Thank you once again! I just realized that the code updates each time a new M15 bar starts. That’s why I don’t need that for loop.
John
Hi,
Just for information, Nicolas proposed the indicator there: https://www.prorealcode.com/topic/time-anchored-vwap/