PureBytes Links
Trading Reference Links
|
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.
>
>
>
|