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

Re: [amibroker] AFL example request



PureBytes Links

Trading Reference Links

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() ) );

----- Original Message -----
From: richpach2
Sent: Friday, October 24, 2008 12:34 AM
Subject: [amibroker] AFL example request

Hello,

Can someone please post a simple example for ValueWhen and LastValue
functions? I looked at the Function Reference Guide and still do not
get it. All AFL examples where these functions are used are too complex
to interpret in context of entire code. I just need something that
shows how to use each function and highlights the difference between
them.

Kind Regards
Richard

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___