logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Mokwit  
#1 Posted : Monday, August 21, 2006 5:02:34 AM(UTC)
Mokwit

Rank: Member

Groups: Registered, Registered Users
Joined: 9/11/2005(UTC)
Posts: 16

Here is a useable VAP indicator but it would be better if

1) It started from the left hand side not the right (most important)

2) There were no lines delieating the outline of the box

3) All the VAP lines were max not min thickness

It would be thought that the above would be eeasy to do using standard controls (eg right to left) or the indicator inputs but it is not e.g when changing VAP line thickness with indicator inputs it only changes one and the matter is complicated by the indicator drawing different numbers each time. Changing it via the coding is a bit daunting, for me at least..........

{Volume By Price 12-C}
D:=Input("Periods, 0=Full Chart",0,2000,100);
D:=LastValue(If(D=0,LastValue(Cum(1)-1),D));
N:=Input("% Scaling in Box, 1=None",1,100,50);
F:=LastValue(Cum(1));
A:=F-D < Cum(1); {window period}
B:=LastValue(Cum(If(A,V,0))); {window volume}
Q:=LastValue(HighestSince(1,A=0,C));
R:=LastValue(LowestSince(1,A=0,C));
I:=(Q-R)/12; {range increment}
{accumulated volume for each price range}
X1:=LastValue(Cum(If(C<(R+I) AND A,V,0))/B);
X2:=LastValue(Cum(If(C>=(R+I) AND C<(R+I*2) AND A,V,0))/B);
X3:=LastValue(Cum(If(C>=(R+I*2) AND C<(R+I*3) AND A,V,0))/B);
X4:=LastValue(Cum(If(C>=(R+I*3) AND C<(R+I*4) AND A,V,0))/B);
X5:=LastValue(Cum(If(C>=(R+I*4) AND C<(R+I*5) AND A,V,0))/B);
X6:=LastValue(Cum(If(C>=(R+I*5) AND C<(R+I*6) AND A,V,0))/B);
X7:=LastValue(Cum(If(C>=(R+I*6) AND C<(R+I*7) AND A,V,0))/B);
X8:=LastValue(Cum(If(C>=(R+I*7) AND C<(R+I*8) AND A,V,0))/B);
X9:=LastValue(Cum(If(C>=(R+I*8) AND C<(R+I*9) AND A,V,0))/B);
X10:=LastValue(Cum(If(C>=(R+I*9) AND C<(R+I*10) AND A,V,0))/B);
X11:=LastValue(Cum(If(C>=(R+I*10) AND C<(R+I*11) AND A,V,0))/B);
X12:=LastValue(Cum(If(C>=(R+I*11) AND A,V,0))/B);
B:=Max(Max(X1,X2),Max(X3,X4));
B:=Max(Max(B,X5),Max(X6,X7));
B:=Max(Max(B,X8),Max(X9,X10));
B:=Max(B,Max(X11,X12));
B:=If(N=1,N,B*100)/N; {set window % usage}
{top of window, HHV for period}
ValueWhen(1,F-D=Cum(1),Q);
{proportion of volume for each price range}
ValueWhen(1,F-Int(X12*D/B)=Cum(1),R+I*11.5);
ValueWhen(1,F-Int(X11*D/B)=Cum(1),R+I*10.5);
ValueWhen(1,F-Int(X10*D/B)=Cum(1),R+I*9.5);
ValueWhen(1,F-Int(X9*D/B)=Cum(1),R+I*8.5);
ValueWhen(1,F-Int(X8*D/B)=Cum(1),R+I*7.5);
ValueWhen(1,F-Int(X7*D/B)=Cum(1),R+I*6.5);
ValueWhen(1,F-Int(X6*D/B)=Cum(1),R+I*5.5);
ValueWhen(1,F-Int(X5*D/B)=Cum(1),R+I*4.5);
ValueWhen(1,F-Int(X4*D/B)=Cum(1),R+I*3.5);
ValueWhen(1,F-Int(X3*D/B)=Cum(1),R+I*2.5);
ValueWhen(1,F-Int(X2*D/B)=Cum(1),R+I*1.5);
ValueWhen(1,F-Int(X1*D/B)=Cum(1),R+I*0.5);
{left and bottom of window, LLV for period}
ValueWhen(1,F-D<=Cum(1) AND F-D>Cum(1)-2,If(A,R,Q));

So: If anyone who can code is interested enough to have a look that would be appreciated. Alternatively, if anyone knows of a VAP indicator that does what I want the modified version of the above to do straight out of the box that would be appreciated.

With thanks to the original author and apologies for credits being lost in mists of time.

mstt  
#2 Posted : Monday, August 21, 2006 5:12:55 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Mokwit

As the author of the above code I’m probably as aware as anyone of its limitations.

There is a version of Volume at Price that starts from the left side of the chart. This is not any more difficult to do than plotting from the right side. What is not possible as far as I know is to start the plot from the first displayed bar. A VAP indicator based on the left side of the chart really needs to start at the first loaded bar, and it’s not possible to automate it starting from the first displayed bar. When the two are one and the same bar there’s not a problem. Otherwise most or all of the VAP would be unseen off to the left. I don’t know of a practical way to overcome that situation in MetaStock.

The box outline can be removed easily enough. I think I created one version of VAP where the box was optional. Commenting out the line immediately below each of the following headings should do the trick.

{top of window, HHV for period}

{left and bottom of window, LLV for period}

Line definitions are set manually on each chart or imbedded in a template. They cannot be controlled from within the formula itself.

Roy

MetaStock Tips & Tools

Mokwit  
#3 Posted : Wednesday, August 23, 2006 5:52:15 AM(UTC)
Mokwit

Rank: Member

Groups: Registered, Registered Users
Joined: 9/11/2005(UTC)
Posts: 16

Roy, many thanks for your explanations and suggestions and thank you also for placing the indicator in the public domain.
Spaceant  
#4 Posted : Wednesday, August 23, 2006 9:32:11 AM(UTC)
Spaceant

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2005(UTC)
Posts: 182

Roy,

How does the above code compared with the following code that you developed earlier?

Sa

{Volume By Price 25}

{?006 Roy Larsen, www.metastocktips.com}

d:=Input("Bars to Include",1,9999,100);

n:=Input("Scaling Factor",1,99,5);

k:=Input("Plot Frame?",0,1,1);

y:=Cum(1);f:=LastValue(y);z:=f-1=y;

d:=LastValue(If(d>=f,f-1,d));a:=(f-d<y)*(y>1);

g:=a*V;b:=LastValue(Cum(g));

q:=LastValue(HighestSince(1,a=0,C));

r:=LastValue(LowestSince(1,a=0,C));

i:=(q-r)/25;u:=r+i*.5;m:=n*d/b;

x:=LastValue(Cum((C<(r+i))*g));ValueWhen(1,f-x*m<y,u);

x:=LastValue(Cum((C>=(r+i))*(C<(r+i*2))*g));ValueWhen(1,f-x*m<y,u+i);

x:=LastValue(Cum((C>=(r+i*2))*(C<(r+i*3))*g));ValueWhen(1,f-x*m<y,u+i*2);

x:=LastValue(Cum((C>=(r+i*3))*(C<(r+i*4))*g));ValueWhen(1,f-x*m<y,u+i*3);

x:=LastValue(Cum((C>=(r+i*4))*(C<(r+i*5))*g));ValueWhen(1,f-x*m<y,u+i*4);

x:=LastValue(Cum((C>=(r+i*5))*(C<(r+i*6))*g));ValueWhen(1,f-x*m<y,u+i*5);

x:=LastValue(Cum((C>=(r+i*6))*(C<(r+i*7))*g));ValueWhen(1,f-x*m<y,u+i*6);

x:=LastValue(Cum((C>=(r+i*7))*(C<(r+i*8))*g));ValueWhen(1,f-x*m<y,u+i*7);

x:=LastValue(Cum((C>=(r+i*8))*(C<(r+i*9))*g));ValueWhen(1,f-x*m<y,u+i*8);

x:=LastValue(Cum((C>=(r+i*9))*(C<(r+i*10))*g));

ValueWhen(1,f-x*m<y,u+i*9);

x:=LastValue(Cum((C>=(r+i*10))*(C<(r+i*11))*g));

ValueWhen(1,f-x*m<y,u+i*10);

x:=LastValue(Cum((C>=(r+i*11))*(C<(r+i*12))*g));

ValueWhen(1,f-x*m<y,u+i*11);

x:=LastValue(Cum((C>=(r+i*12))*(C<(r+i*13))*g));

ValueWhen(1,f-x*m<y,u+i*12);

x:=LastValue(Cum((C>=(r+i*13))*(C<(r+i*14))*g));

ValueWhen(1,f-x*m<y,u+i*13);

x:=LastValue(Cum((C>=(r+i*14))*(C<(r+i*15))*g));

ValueWhen(1,f-x*m<y,u+i*14);

x:=LastValue(Cum((C>=(r+i*15))*(C<(r+i*16))*g));

ValueWhen(1,f-x*m<y,u+i*15);

x:=LastValue(Cum((C>=(r+i*16))*(C<(r+i*17))*g));

ValueWhen(1,f-x*m<y,u+i*16);

x:=LastValue(Cum((C>=(r+i*17))*(C<(r+i*18))*g));

ValueWhen(1,f-x*m<y,u+i*17);

x:=LastValue(Cum((C>=(r+i*18))*(C<(r+i*19))*g));

ValueWhen(1,f-x*m<y,u+i*18);

x:=LastValue(Cum((C>=(r+i*19))*(C<(r+i*20))*g));

ValueWhen(1,f-x*m<y,u+i*19);

x:=LastValue(Cum((C>=(r+i*20))*(C<(r+i*21))*g));

ValueWhen(1,f-x*m<y,u+i*20);

x:=LastValue(Cum((C>=(r+i*21))*(C<(r+i*22))*g));

ValueWhen(1,f-x*m<y,u+i*21);

x:=LastValue(Cum((C>=(r+i*22))*(C<(r+i*23))*g));

ValueWhen(1,f-x*m<y,u+i*22);

x:=LastValue(Cum((C>=(r+i*23))*(C<(r+i*24))*g));

ValueWhen(1,f-x*m<y,u+i*23);

x:=LastValue(Cum((C>=(r+i*24))*(C<(r+i*25))*g));

ValueWhen(1,f-Int(x*m)=y,u+i*24);

x:=(f-d=y)*k;ValueWhen(1,x,q);ValueWhen(1,Alert(x,2),If(x,q,r));

mstt  
#5 Posted : Wednesday, August 23, 2006 5:57:24 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Spaceant

The ability to remove the enclosing box is one difference, and the number of volume bars another. The theory behind each is the same except for the scaling method. I think the one immediately above was an exercise in getting as many volume lines into one formula as space would permit.

Roy

MetaStock Tips & Tools

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.