Shouldn't the cumulative volume be relevant to the volume total?
Original:
Value2 = ((UpTicks[Value1] + DownTicks[Value1])/ShareW) *
(Square(AvgPrice[Value1]-VolWAPValue)) ;
Modified:
Value2 = ((UpTicks[Value1] + DownTicks[Value1])/ShareW[Value1]) *
(Square(AvgPrice[Value1]-VolWAPValue)) ;
vars:
PriceW ( 0 ),
ShareW ( 0 ),
Count ( 0 ),
VolWAPValue ( 0 ),
VolWAPVariance ( 0 ),
VolWAPSD ( 0 ),
Class ("PVP"),
MyPVP ( 0 ) ;
if
date > date[1]
then
begin
PriceW = 0 ;
ShareW = 0;
Count = -1 ;
Value1 = 0 ;
Value2 = 0 ;
VolWAPValue = 0 ;
end;
PriceW = PriceW + (close {AvgPrice} * (UpTicks+DownTicks)) ;
ShareW = ShareW + (UpTicks+DownTicks) ;
Count = Count + 1 ;
Value3 = 0 ;
if
ShareW > 0
then
VolWAPValue = PriceW / ShareW ;
For
Value1 = 0 To Count
Begin
if
0 < ShareW[Value1]
then
Value2 = ((UpTicks[Value1] + DownTicks[Value1])/ShareW[Value1]) *
(Square(AvgPrice[Value1]-VolWAPValue)) ;
Value3 = Value3 + Value2 ;
End;
VolWAPVariance = Value3 ;
VolWAPSD = round2fraction(SquareRoot(VolWAPVariance)) ;
Plot1(VolWAPValue, "VWAP");
Plot2(VolWAPValue + VolWAPSD, "1Up");
Plot3(VolWAPValue - VolWAPSD, "1 Dn");
Plot4(VolWAPValue + (2*VolWAPSD), "2Up");
Plot5(VolWAPValue - (2*VolWAPSD), "2Dn");
Plot6(VolWAPValue + (1.5*VolWAPSD), "1.5 Up");
Plot7(VolWAPValue - (1.5*VolWAPSD), "1.5 Dn");
Plot8(VolWAPValue + (.5*VolWAPSD), ".5 Up");
Plot9(VolWAPValue - (.5*VolWAPSD), ".5 Dn");