Hello Richard - Hope you don't think I'm talking down to you but
if you're in this for the long run this is what I would do (I did)
1) I purchased a product called InfoSelect and have
collected about several years of clips and programs that looked interesting.
IS is from Microlog.
Has been around for many years. It's an
info database and indexes every character of every thing you clip and paste into
the system.
2) Understand how AB stores the data, a time series or
arrays. Functions process and return arrays and scalars and the
function description will let you know. ValueWhen returns an array
and LastValue returns a scalar or number as documented in AB.
3) Use Explore - one of the best ways to "see" what's
happening. Like so.
Hope this helps
Joe
An Exploration Example
Filter = 1;
Array1 = ValueWhen(Close> Open, DateTime());
Array2 = ( ValueWhen(
Status("firstbarinrange"),BarIndex() ) );
Array3 = ( ValueWhen(
Status("lastbarinrange"),BarIndex() ) );
AddColumn
(DateTime(),"Date",formatDateTime);
AddColumn
( Array1, "Date when Close > Open", formatDateTime
);
AddColumn
(Array2,"Numb2");
// Meets the condition only at the last bar in the
range FROM TO setting - change the range to demonstrate
AddColumn
(Array3,"Numb3");
// A number and doesn't change over the Explore
AddColumn
(LastValue(DateTime()),"Last
Date",formatDateTime);
//
====================================================================================================
1st Sample Clip
dt = DateTime();
Price1 = LastValue( ValueWhen(dt==StrToDateTime("12/05/2005"), C
) );
Price2 = LastValue( ValueWhen(dt==StrToDateTime("1/06/2006"), C
) );
Price3 = LastValue( ValueWhen(dt==StrToDateTime("2/07/2007"), C
) );
AddColumn(Price1 ,"Dec 5, 2005");
AddColumn(Price2 ,"Jan 6, 2006");
AddColumn(Price3 ,"Feb 7, 2007");
2nd Clip Example
// Get the start and end bar indexes
start = LastValue( ValueWhen( Status( "firstbarinrange" ),
BarIndex() ) );
end = LastValue( ValueWhen( Status( "lastbarinrange" ),
BarIndex() ) );
3rd Clip
// End User Variables
// ----------------------------------
StartBar = LastValue( ValueWhen(
Status("firstbarinrange"),BarIndex() ) );
FinishBar = LastValue( ValueWhen(
Status("lastbarinrange"),BarIndex() ) );