PureBytes Links
Trading Reference Links
|
Guy ...
Not sure what your MXXX is, but have a look at ROC which compares today's
value with one N days ago.
However, you still need one statement per lookback
MS does not provide loops like Trade Station so that a variable can be used
as a subscript to reference back data.
best of luck
Martin
----- Original Message -----
From: "Guy Tann" <grt@xxxxxxxxxxxx>
To: <metastock@xxxxxxxxxxxxx>
Sent: Friday, August 18, 2000 10:32 AM
Subject: RE: Calculation question again
> Martin,
>
> Thanks for the technique. I will try it tonight. I read the manual twice
> (once is unusual for me) and never saw that cum() function.
>
> That second technique in Ton's post didn't work, or I'm doing something
> wrong.
>
> I have some more testing to do tonight until I get down to the
nitty-gritty
> calculation using ref(). Briefly, I need to do the following.
>
> For value MXX, I need to calculate the following:
>
> MXX;
> One:=MXX - MXX back one day;
> Two:=MXX - MXX back two days;
> And so on to MXX - MXX back 18 days.
>
> I have already coded this using the ref() function, but haven't got to the
> point when I can test it yet as I have to complete verifying all of the
work
> leading up to calculating MXX. I hope to complete that tonight. If you
> know of a sneaky way to do this other than using ref() let me know.
>
> Thanks,
>
> Guy
>
> Never be afraid to try something new. Remember, amateurs built the ark,
> professionals built the Titanic.
>
> -----Original Message-----
> From: owner-metastock@xxxxxxxxxxxxx
[mailto:owner-metastock@xxxxxxxxxxxxx]On
> Behalf Of Martin Haesler
> Sent: Wednesday, August 16, 2000 9:15 PM
> To: metastock@xxxxxxxxxxxxx
> Subject: Re: Calculation question again
>
> Guy ... suggest you do the following
>
> kount:=if(increment condition,1,if(decrement condition,-1,0));
> runningtotal:=cum(kount);
>
> kount will be +1,-1, or 0 depending on which condition (if any) exists
> running total will accumulate kount, adding one when an increment is
> required, subtracting one when a decrement is required, and leaving it the
> same if neither is warranted.
>
> I use this method often when determining cumulative profit in an
indicator.
> It is much faster because it eliminates the "previous" function.
>
> Regards ... Martin from Oz
>
>
> ----- Original Message -----
> From: "Guy Tann" <grt@xxxxxxxxxxxx>
> To: "Metastock User Group" <metastock-list@xxxxxxxxxxxxx>
> Sent: Thursday, August 17, 2000 2:20 AM
> Subject: Calculation question again
>
>
> > List,
> >
> > Well, I'm still trying to move our Intermediate Term Signals into MS and
> I'm
> > still having problems. I have completed all of the coding and am now in
> the
> > debugging stage.
> >
> > First, here are two calculations that I've tried. One works (the one
with
> > PREV) and one doesn't. After all of the help the last time around, I
> > naturally tried the Ref() function because everyone said it was the
> > preferable approach.
> >
> > Any and all help is appreciated.
> >
> > COMHCRR:= If( FmlVar("COM-CNTRY","COMCR") > 0 , PREV + 1 , If(
> > FmlVar("COM-CNTRY","COMCR") < 0 , PREV - 1 , PREV ) );
> > COMHCRR;
> >
> > COMHCRT:= If( FmlVar("COM-CNTRY","COMCR") > 0 , Ref( COMHCRT, -1 ) + 1
,
> > If( FmlVar("COM-CNTRY","COMCR") < 0 , Ref( COMHCRT , -1 ) - 1 , Ref(
> > COMHCRT , -1 ) ) );
> > COMHCRT;
> >
> > This is a simple calculation where I accumulate a total, adding 1 if the
> > indicator > 0, subtracting 1 if it is < 0 and just carrying the
previous
> > day's value forward if there is no change. Nothing sophisticated.
> >
> > My second minor problem is that the answer is incorrect. I've exported
my
> > MS SPI data into a Clipper database to insure an identical test data
set.
> > Based upon that, the results should be identical, especially since this
> > calculation is so simple. I haven't double-checked that COMCR
calculation
> > in both systems, but I will right now. I should say that I had verified
> > that calculation before but I will do it again just to make sure nothing
> > else managed to get screwed up.
> >
> > Guy
> >
> > Never be afraid to try something new. Remember, amateurs built the ark,
> > professionals built the Titanic.
> >
> >
> >
>
>
|