Intrabar VWAP not working correctly
Posted: 14 Sep 2011
Hi, i am trying to calculate an intrabar VWAP, ie the VWAP of each individual bar which i will compare to the close of the bar to see if it is above or below the close etc.. I am using intrabarpersist for this and have tried it with minute, tick and range charts and every time the returned intrabar VWAP is just the close of the bar which is not right. I do have "Update on every tick" checked under the study properties. The exact code i am using is below. I tried using barstatus to reset the PriceW and ShareW variables at the end of each bar but that did not seem to work either. This should work, anyone have any ideas why this does not work, or any suggestions on how to get it to work?
Many thanks for your help with this,
Many thanks for your help with this,
Code: Select all
vars:
intrabarpersist PriceW(0),
intrabarpersist ShareW(0),
IntrabarVWAP(0);
If time <> time[1] then begin
PriceW = 0;
ShareW = 0;
end;
PriceW = PriceW + (Close * (Upticks + DownTicks));
ShareW = ShareW + (Upticks + Downticks);
If ShareW > 0 then IntrabarVWAP = PriceW / ShareW;
Plot1(IntrabarVWAP,"BarVWAP");