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

Re: [Metastockusers] Simple Code Question



PureBytes Links

Trading Reference Links

Hi Invest
 
 
Selecting the first loaded bar and its price is simple. However, your question suggests that you want the first "visible" bar and I think this would be impossible unless you were displaying all open bars. Unloading unwanted bars is possible but not something you'd want to do frequently.
 
Cum(1)=1 identifies the first loaded bar (for chart, exploration or system test). Finding the price associated with that bar is as simple as
ValueWhen(1,Cum(1)=1,C).
 
One way that you could reference the price on a bar that is not the first bar loaded would be to use a "date spike" to flag a particular date, and use that to trigger the ValueWhen()

Sd:=Input("Start day"  ,1,31,1);
Sm:=Input("Start month",1,12,1);
Sy:=Input("Start year" ,1980,2010,2002);
Start:=(DayOfMonth()>=Sd AND Month()=Sm AND
Year()=Sy) OR Year()>Sy OR (Year()=Sy AND
Month()>Sm);
Trigger:=Start and ValueWhen(2,1,Start)=0;
ValueWhen(1,Trigger,C);
 
If you then wanted to spread that value across the entire chart rather than starting at the nominated date (but still reference the price for the nominated date) then you could change the last line to
 
LastValue(ValueWhen(1,Trigger,C));
 
There are probably a number of other ways to access prices on particular bars, but it's difficult to try and guess what would work for you.
 
 
Regards
 
Roy
 
 
----- Original Message -----
From: invest0890
Sent: Saturday, September 17, 2005 5:35 PM
Subject: [Metastockusers] Simple Code Question

Is there any way in Metastock to reference the first value in the
visible chart?

Lets say I want to use the close of the first value in whatever
metastock chart I'm looking at as a 'base' for an indicator I build.
How would I get metastock to look at that first close in the chart? 

I see the "bar since" function but I may not want a fixed value. I may
want to look at a one week chart one time and a three month chart
another. I want the program to simply know to use the first day on the
chart but I know not how to reference it.




SPONSORED LINKS
Business finance uk Business finance course Business finance online course
Business finance class Small business finance Business finance small software


YAHOO! GROUPS LINKS