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

[EquisMetaStock Group] Re: First value of MS arrays



PureBytes Links

Trading Reference Links


DF, try this code:

=========
DateValue
=========
---8<----------------

{ Plots Data Array value on given date - v2.0 }
{ http://www.metastocktools.com }

{ Date input }
StDay:=Input("Day  [1~31]",1,31,1);
StMnth:=Input("Month  [1~12]",1,12,1);
StYear:=Input("Year  [1800~2200]",
 1800,2200,2005);
plot:=Input("[1]DateValue,  [2]date signal,  [3]yymmdd date",1,3,1);

{ Data Array }
DataArray:=CLOSE;

{ First available Date signal }
binary:=Year()>StYear
 OR (Year()=StYear AND (Month()>StMnth
 OR Month()=StMnth AND DayOfMonth()>=StDay));
signal:=binary AND Alert(binary=0,2);

{ Data Array value on first available date }
DateValue:=ValueWhen(1,signal,DataArray);

{ Extend DateValue to whole chart }
DateValue:=LastValue(DateValue);

{ Signal yymmdd value }
yy:=ValueWhen(1,signal,Year());
yy:=Int(Frac(yy/100)*100+.5);
mm:=ValueWhen(1,signal,Month());
dd:=ValueWhen(1,signal,DayOfMonth());
yymmdd:=LastValue(yy*10000+mm*100+dd);

{ Plot on price chart }
If(plot=1,DateValue,
 If(plot=2,DateValue*(signal/20+1),
  yymmdd))

---8<----------------

The above code will return the first trading date for 2005, i.e. 3/
Jan/2005, or 50103.  Unfortunately MetaStock cannot plot leading 
zeroes in indicator outputs, so you're stuck with ymmdd until 2010.


> PS. Where can one buy one's very own Jose de Silva?

There's a Jose Silva for rent (cheap at US$40/hr) at
http://www.metastocktools.com  ;)

jose '-)



--- In equismetastock@xxxxxxxxxxxxxxx, "deepfoobar" <deepfoobar@xxxx> 
wrote:
> 
> Jose,
> 
> How would you collect back the date values if you needed them as
> well as the price (or whatever array was desired) on the given date
> input?
> Can one collect params from the formula? Can they be coerced into
> the nasty YYMMDD format?
> 
> In other words I enter the date I want, say 2004, 03 (March), 24
> (day). Can the legit start date then be returned since the date
> entered might not be precisely the one used? [e.g the user enters a
> non-trading day for which there is no data].
> 
> I happen to be using an older, persnicked .dll that doesn't like
> variables (solved by lastValue) but expects the date back in this
> format.
> 
> PS. Where can one buy one's very own Jose de Silva?
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx>
> wrote:
> 
> First value in a data array:
> 
> ==========
> FirstValue
> ==========
> ---8<----------------
> DataArray:=OPEN;
> FirstValue:=ValueWhen(1,Cum(1)=1,DataArray);
> 
> FirstValue
> ---8<----------------
> 
> 
> Value of a data array on a given date:
> 
> =========
> DateValue
> =========
> ---8<----------------
> 
> { Plots Data Array value on given date }
> { http://www.metastocktools.com }
> 
> { Date input }
> StDay:=Input("Day  [1~31]",1,31,1);
> StMnth:=Input("Month  [1~12]",1,12,1);
> StYear:=Input("Year  [1800~2200]",
>  1800,2200,2005);
> 
> { Data Array }
> DataArray:=CLOSE;
> 
> { First available Date signal }
> binary:=Year()>StYear
>  OR (Year()=StYear AND (Month()>StMnth
>  OR Month()=StMnth AND DayOfMonth()>=StDay));
> signal:=binary AND Alert(binary=0,2);
> 
> { Data Array value on first available date }
> DateValue:=ValueWhen(1,signal,DataArray);
> 
> { Extend DateValue to whole chart }
> DateValue:=LastValue(DateValue);
> 
> { Plot DateValue }
> DateValue
> 
> ---8<----------------
> 
> 
> jose '-)
> http://www.metastocktools.com
>
>
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "manelcabedo" <manelcabedo@xx
> .. wrote:
>
>
> Hi,
> 
> A question for the experts:
> 
> Is there any way of knowing the value of the first element of a MS 
> array? Or still better: Is it possible to know the value of a MS
> array element for a given date?
> 
> Thanks in advance.
> 
> Manuel





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> 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/