PureBytes Links
Trading Reference Links
|
Tom, I've added loops in your code until MetaStock run out of
"constant" memory space.
This and other limitations can be avoided by chaining a few pseudo-
loop indicators together.
jose '-)
--- In Metastockusers@xxxxxxxxxxxxxxx, "Tom Sprunger" <tlsprunger@xxxx
> wrote:
>
> nice additions, Jose. I assume you added loops until you ran out of
space?
>
> Tom
> ----- Original Message -----
> From: "Jose" <josesilva22@xxxx>
> To: <Metastockusers@xxxxxxxxxxxxxxx>
> Sent: Wednesday, July 21, 2004 9:05 PM
> Subject: [Metastockusers] Re: Pseudo Loop and Rafter Moving Trend/
Linear
> Regression Indicator
>
>
> > Good work Tom.
> >
> > This is your code with a few extra loops added:
> >
> > ---8<-------------------------
> >
> > { Example of MetaStock pseudo-loop code,
> > MetaStock Linear Regression Indicator }
> > { Tom Sprunger 2004 }
> >
> > pds:=Input("Lin Reg periods",1,37,21);
> > y:=Input("use Open=1 High=2 Low=3 Close=4 WClose=5 P=6",1,6,4);
> >
> > y:=If(y=1,O,If(y=2,H,If(y=3,L,If(y=5,WC(),If(y=6,P,C)))));
> > k1:=(pds+1)/3;
> >
> > { Start pseudo loop }
> > x:=(pds-k1)*y;
> > n:=pds-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-1),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-2),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-3),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-4),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-5),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-6),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-7),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-8),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-9),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-10),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-11),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-12),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-13),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-14),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-15),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-16),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-17),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-18),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-19),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-20),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-21),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-22),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-23),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-24),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-25),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-26),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-27),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-28),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-29),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-30),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-31),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-32),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-33),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-34),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-35),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-36),x);
> > n:=n-1;
> > x:=If(n>0,x+(n-k1)*Ref(y,-37),x);
> > { End pseudo loop }
> >
> > k2:=6/(pds*(pds+1));
> > wt:=x*k2;
> >
> > wt
> >
> > ---8<-------------------------
> >
> > jose '-)
> >
> >
> >
> > --- In Metastockusers@xxxxxxxxxxxxxxx, "Tom Sprunger"
<tlsprunger@xxxx
> > > wrote:
> > > A few days ago I posted a question on a formula. The answer was
I
> > couldn't
> > > do it easily because it required a loop which Metastock does not
> > support. A
> > > good example of hard coding was presented. However, I took up
the
> > challenge
> > > to perform a loop in Metastock. What I came up functions like a
> > loop. The
> > > disadvantage is that there are limits to how many iterations can
be
> > done in
> > > the loop, basically you run out of room.
> > >
> > > The formula below is for Rafter's Moving Trend, which is the
same as
> > the
> > > Linear Regression Indicator in Metastock.
> > >
> > > the loop implements the below
> > >
> > > n=20;
> > > for(i = n; i > 0; i--)
> > > sum += (i - (n + 1) / 3) * close(i - n);
> > >
> > > I used the ability to do x=x+y and the ability to reuse a
variable,
> > then
> > > put in an if statement to see if the loop was finished.
> > >
> > > Hope this can help in the future
> > >
> > > Tom
> > >
> > > --- Rafter Moving Trend, or the Metastock Linear Regression
> > Indicator ---
> > > pds:=20; {must be between 1 and 30}
> > > k1:=(pds+1)/3;
> > > k2:=6/(pds*(pds+1));
> > > n:=pds;
> > >
> > > {start pseudo loop}
> > > x:=(n-k1)*CLOSE; {"0" bar}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-1 bar}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-3}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-6}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-9}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-12}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-15}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-18}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-21}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-24}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-27}
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds)));
> > > n:=n-1;
> > > x:=If(n<=0,x,x+(n-k1)*Ref(C,(n-pds))); {-30}
> > > {end pseudo loop}
> > >
> > > wt:=x*k2;
> > > wt
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/zMEolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Metastockusers/
<*> To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|