Saturday, March 15, 2008

Volatility vs VWAP





vars:
PriceW(0), ShareW(0), Count(0), VolWAPValue(0), VolWAPVariance(0), VolWAPSD(0), aa(0), bb(0);

if date > date[1] then begin
PriceW = 0; ShareW = 0; Count = -1; Value1 = 0; Value2 = 0; VolWAPValue = 0; end;
PriceW = PriceW + (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
Value2 = ((UpTicks[Value1]+DownTicks[Value1])/ShareW) * (Square(AvgPrice[Value1]-VolWAPValue));
Value3 = Value3 + Value2;
End;
VolWAPVariance = Value3;
VolWAPSD = SquareRoot(VolWAPVariance);
value1=volwapsd;
value2=(value1[203]+value1[406]+value1[609])/3;
value3=(value1+value2)/2;
value4=value3*2;

Plot1(value1, "vwap");
if time<1100 then begin
Plot2(value2, "3-Day Avg");
end;
if time>1000 then begin
Plot4(4.25,"-");
Plot6(6.25,"+");
end;

condition1=time>630 and time<730;
condition2=time>730 and time<830;
condition3=time>830 and time<930;
condition4=time>930 and time<1030;
condition5=time>1030 and time<1130;
condition6=time>1130 and time<1315;

if condition1 then
setplotcolor(2, blue);
if condition2 then
setplotcolor(2, red);
if condition3 then
setplotcolor(2, blue);
if condition4 then
setplotcolor(2, red);
if condition5 then
setplotcolor(2, blue);
if condition6 then
setplotcolor(2, red);





0 comments: