Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 12/14/2009(UTC) Posts: 140 Location: Austria
|
Try this code. For variable j use more than number of bars per day but less than number of bars per week. I have tested this code only with intraday test-data I had for some days - so I couldn't really check if it works properly. With variable x I calculate the last available volume (not equal 0) divided by the avg. volume for the day.. (this is only done as example, here you have to change it to your formula/idea) the last row of the code only shows the result after the last bar of the day... Code:
{example for average effective volume by vienna}
{j = greater then bars per day, but less than 4x bars per day}
j:=1500;
n:=DayOfWeek();
n;
mycount1:=If(n=1,Sum(If(C<>Ref(C,-1) AND n=1,1,0),j),0);
mycount2:=If(n=2,Sum(If(C<>Ref(C,-1) AND n=2,1,0),j),0);
mycount3:=If(n=3,Sum(If(C<>Ref(C,-1) AND n=3,1,0),j),0);
mycount4:=If(n=4,Sum(If(C<>Ref(C,-1) AND n=4,1,0),j),0);
mycount5:=If(n=5,Sum(If(C<>Ref(C,-1) AND n=5,1,0),j),0);
avgvol1:=If(mycount1=0,0,Sum(If(n=1 AND C<>Ref(C,-1),V,0),j)/mycount1);
avgvol2:=If(mycount2=0,0,Sum(If(n=2 AND C<>Ref(C,-1),V,0),j)/mycount2);
avgvol3:=If(mycount3=0,0,Sum(If(n=3 AND C<>Ref(C,-1),V,0),j)/mycount3);
avgvol4:=If(mycount4=0,0,Sum(If(n=4 AND C<>Ref(C,-1),V,0),j)/mycount4);
avgvol5:=If(mycount5=0,0,Sum(If(n=5 AND C<>Ref(C,-1),V,0),j)/mycount5);
lastV:=If(V=0,PREV,V);
x:=If(n=1,If(avgvol1=0,0,lastV/avgvol1),0);
x:=If(n=2,If(avgvol2=0,0,lastV/avgvol2),x);
x:=If(n=3,If(avgvol3=0,0,lastV/avgvol3),x);
x:=If(n=4,If(avgvol4=0,0,lastV/avgvol4),x);
x:=If(n=5,If(avgvol5=0,0,lastV/avgvol5),x);
x;
If(n<>Ref(n,-1),Ref(x,-1),0);
Try the code and change the colors of the different result-lines, then you will see what it is doing..
|