[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Metastockusers] formula question



PureBytes Links

Trading Reference Links

Roy,   the java script formula says

n is a constant.
set i=n,
then for each value of i between 20 and 1, start with i=20 and decrement  i
by 1 on each pass,
summing up the values of the equation
(i - (n + 1) / 3) * close(i - n)

The way the bars are identififed in this program is by a numbering scheme
like Metastock uses.
Hence, the close(0) = close in metastock terms,  and close(-1) is the same
as Ref(close,-1), etc.

So, this starts out with a value i=20 and does a loop until i=1.
the first pass through it evaluates
sum=(20-(20+1)/3)*close(20-20))
The next pass through it is
sum=(19-(20+1)/3)*Ref(close,(19-20)) +prev
The next pass through it becomes
sum=(18-(20+1)/3)*Ref(close,(18-20)) + prev
and so on until it stops when the value of i becomes zero.

There is nothing magic about decrementing the value of i.
you could also start with i=1 and increment by 1 until you get to 20.
In that case the first pass through would be
sum=(1-(20+1)/3)*Ref(close(1-20)
etc.

The part I can't figure out is how to do the increment/decrement portion of
i.
That is because the value i changes inversely to the bar number.  When i is
small, the bar  number is the oldest (most negative)... When i is max the
bar is the current one.

Of course one could hard code it with a long series of Ref(Close,-x)
expressions, but then you can not make n a variable
Did I make it clear or am I still confusing you?


Tom

----- Original Message ----- 
From: "Roy Larsen" <rlarsen@xxxxxxxxxxxxxx>
To: <Metastockusers@xxxxxxxxxxxxxxx>
Sent: Monday, July 19, 2004 6:59 PM
Subject: Re: [Metastockusers] formula question


> Tom
>
> What is it doing in English?
>
> Roy
>
> ----- Original Message ----- 
> From: "tlsprunger" <tlsprunger@xxxxxxxxxxx>
> To: <Metastockusers@xxxxxxxxxxxxxxx>
> Sent: Tuesday, July 20, 2004 3:57 AM
> Subject: [Metastockusers] formula question
>
>
> > I wonder if any wizards can help me with following.
> >
> > I have a formula written in Java Script similar to the following:
> > n=20;
> > for(i = n; i > 0; i--)
> > sum += (i - (n + 1) / 3) * close(i - n);
> >
> > Now how would I convert that to Metastock language?
> >
> > note that when the current bar is the "0" bar, the value of i is 20.
> > When the current bar is the "-1" bar, the value of i is 19, etc.
> >
> > For example if the part "i-" were not in the equation, then I could
> > do the following:
> > n=20;
> > x1=n+1)/3)*C;
> > x=sum(x1,n);
> > and it will sum up the values of x1 over the last 20 bars.
> >
> > Now how do I get it to add the "i-" part?
> >
> > Perhaps Metastock can not do this?
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
> 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/