What formula does Zerodha use for VWAP calculation

ms9491
ms9491 edited October 2019 in Java client
Below is my Java code to get VWAP . The vwap obtained from below logic is not matching with what in see in Zerodha.
I am using 20 candles (each of 10 mins in this case). Does Zerodha also uses 20 candles or any other number.
public double getVwap(double[] close, long[] volume){

double vwap = 0.0;
long totVol = 0;

try{

for(int i=close.length-2 ; i>(close.length-22); i--){
double closePr = close[i];
long vol = volume[i];
totVol=totVol+vol;
vwap = vwap+(closePr*vol);
}
vwap = vwap/totVol;

}catch(Exception e){
e.printStackTrace();
}

return vwap;
}
  • sujith
    You can find everything here.
  • hitman1980
    VWAP is calculated from scratch at the start of everyday .. So if u r taking 20 candles from the mid of the day than it won't show u the same figure as in Zerodha charts ..

    Ur calculation need to start from first candle of the day ..
Sign In or Register to comment.