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

Re: [EquisMetaStock Group] A good piece of code for FirstValue



PureBytes Links

Trading Reference Links

Jack

I'm sure Jose won't mind me showing an alternative. In theory it should give
the same result.

  {First Value}
x:=C; {any valid data array}
FirstValue:=ValueWhen(1,Cum(1)=1,x);
FirstValue;

Roy


----- Original Message ----- 
From: "manohohman" <no_reply@xxxxxxxxxxxxxxx>
To: <equismetastock@xxxxxxxxxxxxxxx>
Sent: Thursday, August 28, 2003 7:47 AM
Subject: [EquisMetaStock Group] A good piece of code for FirstValue


> Here's a little piece of code I ran across from Jose. You can put it
> away in your code library. It might come in handy.
>
> {The MetaStock language has many frustrating limitations. A major
> headache is not being able to load an entire data array with the
> first calculated value of the specified data array, such as the first
> Close in all the loaded data.
>
> Here is a FirstValue() function or equivalent, which I believe didn't
> exist... until now:}
>
> x:=C; {or any other valid data array}
> FirstValue:=LastValue(Ref(x,-(LastValue(Cum(1))-1)));
> FirstValue
>
> {But, what if we now need the first value of a conditional
> expression, which doesn't happen to coincide with the first period in
> the loaded data array?
> If we use the FirstValue formula above, the value found will always
> be zero. Not good.
> To get this value:}
>
> x:=C; {or any other price field such as next day's close Ref(C,1)}
> y:=Cross(C,Mov(C,21,E)); {sample condition}
> FirstCond:=LastValue(ValueWhen(LastValue(Cum(y)),y=1,x));
> FirstCond
>
> Jack
>
>
>
>
>
>
> To unsubscribe from this group, send an email to:
> equismetastock-unsubscribe@xxxxxxxxxxxxxxx
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/BefplB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/