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

Re: [EquisMetaStock Group] HELP - Metastock Coding !!!



PureBytes Links

Trading Reference Links

Hi Eric
 
Would this work? You are limited to 40 constants by MetaStock so adding more than 40 components to your formula becomes even more clumsy than that shown, but not difficult to do. There are also ways to reduce the number of N/A bars for this type of formula down from around 40  and closer to the value of D (DD in your formula).
 
The If() function used in the external formula is redundant because all you're really doing is summing a series of logical values where the answer is always one or zero.
 
MetaStock has a LastValue() function and it's easy to simulate a "First Value" function, but there is no simple way to simulate a "Current Value" function, and that's what you need. Using a series of ValueWhen()s (or Ref()s if you prefer) allows you to test the current value of ML against a range of previous CLOSEs. Hope this gives you some inspiration.
 
Regards
 
Roy
 
PS  I have not tested this particular formula in MS but I do know that the principle works.
 
D:=8 {ANY VALUE LESS THAN 40 RETURNED FROM FORMULA};
ML:=(H+L)/2;
X:=(C>=ML)+(D>1)*(ValueWhen(2,1,C)>=ML)+
(D>2)*(ValueWhen(3,1,C)>=ML)+(D>3)*(ValueWhen(4,1,C)>=ML)+
(D>4)*(ValueWhen(5,1,C)>=ML)+(D>5)*(ValueWhen(6,1,C)>=ML)+
(D>6)*(ValueWhen(7,1,C)>=ML)+(D>7)*(ValueWhen(8,1,C)>=ML)+
(D>8)*(ValueWhen(9,1,C)>=ML)+(D>9)*(ValueWhen(10,1,C)>=ML)+
(D>10)*(ValueWhen(11,1,C)>=ML)+(D>11)*(ValueWhen(12,1,C)>=ML)+
(D>12)*(ValueWhen(13,1,C)>=ML)+(D>13)*(ValueWhen(14,1,C)>=ML)+
(D>14)*(ValueWhen(15,1,C)>=ML)+(D>15)*(ValueWhen(16,1,C)>=ML)+
(D>16)*(ValueWhen(17,1,C)>=ML)+(D>17)*(ValueWhen(18,1,C)>=ML)+
(D>18)*(ValueWhen(19,1,C)>=ML)+(D>19)*(ValueWhen(20,1,C)>=ML)+
...
(D>38)*(ValueWhen(39,1,C)>=ML);
X;
 
 
----- Original Message -----
Sent: Wednesday, January 04, 2006 1:00 PM
Subject: [EquisMetaStock Group] HELP - Metastock Coding !!!

DD:=8 {ANY VALUE LESS THAN 40 RETURNED FROM FORMULA};
ML:=(H+L)/2;
ExtFml("Forum.Sum",If(C>=ML,1,0),DD) {ML uses present value to be a
constant}

In this case, ML will be based on different periods' H and L ,
but I would like to count backward for summation by keeping present H
and L as a constant for the rest of calculation.

Does anyone have any idea please?
Thank for any suggestion
Eric

For example

Present
H:=10
L:=8
ML:=9

1 DAY BACKWARD
H:=8
L:=6
ML:=9 {value from present}

2 DAY BACKWARD
H:=7
L:=5
ML:=9 {value from present}

...

8 DAY BACKWARD
H:=8
L:=4
ML:=9 {value from present}









YAHOO! GROUPS LINKS