Many thanks BlowFish for your reply, i have an error when i try to compile my VWAP code, this is the code that i use:
[LegacyColorValue = true];
vars:
PriceW(0),
ShareW(0),
Count(0),
VolWAPValue(0),
VolWAPVariance(0),
VolWAPSD(0),
Class("PVP"),
InfoMap(MapSN.New),
MyPVP(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 = ADE.GetBarInfo(Class, GetSymbolName, ADE.TypeZeroInterval(11,1), ADE.BarID, InfoMap);
MyPVP = MapSN.Get(InfoMap, "PVP");
Plot1(VolWAPValue, "VWAP");
Plot2(VolWAPValue + VolWAPSD, "VWAP1SDUp");
Plot3(VolWAPValue - VolWAPSD, "VWAP1SDDown");
Plot4(VolWAPValue + (2*VolWAPSD), "VWAP2SDUp");
Plot5(VolWAPValue - (2*VolWAPSD), "VWAP2SDDown");
Plot6(VolWAPValue + (3*VolWAPSD), "VWAP3SDUp");
Plot7(VolWAPValue - (3*VolWAPSD), "VWAP3SDDown");
Plot8(MyPVP, "PVP");
when i add your additional code the new VWAP is like this:
[LegacyColorValue = true];
vars:
PriceW(0),
ShareW(0),
Count(0),
VolWAPValue(0),
VolWAPVariance(0),
VolWAPSD(0),
Class("PVP"),
InfoMap(MapSN.New),
MyPVP(0);
Input:
NumberofDays (1),
if date > date[1] then
begin
n = n + 1;
if n = NumberofDays then
begin //reset code goes in here
s = 0;
n = 0;
VWAP1 = VWAP;
SD1 = SD;
VWAP = 0;
SumWeights = 0;
SumWeightsOld = 0;
VWAPOld = 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 = ADE.GetBarInfo(Class, GetSymbolName, ADE.TypeZeroInterval(11,1), ADE.BarID, InfoMap);
MyPVP = MapSN.Get(InfoMap, "PVP");
Plot1(VolWAPValue, "VWAP");
Plot2(VolWAPValue + VolWAPSD, "VWAP1SDUp");
Plot3(VolWAPValue - VolWAPSD, "VWAP1SDDown");
Plot4(VolWAPValue + (2*VolWAPSD), "VWAP2SDUp");
Plot5(VolWAPValue - (2*VolWAPSD), "VWAP2SDDown");
Plot6(VolWAPValue + (3*VolWAPSD), "VWAP3SDUp");
Plot7(VolWAPValue - (3*VolWAPSD), "VWAP3SDDown");
Plot8(MyPVP, "PVP");
but i have an error when i try to compile
'(' Expected
errLine 19, errColumn 3, errLineEnd 19, errColumnEnd 3
causal study: (Function)
errLine 19 it's
if date > date[1] then begin
, you know why? Thank you