PureBytes Links
Trading Reference Links
|
Hi Joe,
Thank you for your reply. This looks like a good example. I learn best
by looking up or testing a simple example of code. My current
collection is not all that big but, when it grows beyond manageable
size, it may be a good idea to use a database to store and search all
records.
Regards
Richard
--- In amibroker@xxxxxxxxxxxxxxx, "Joe Landry" <jelandry@xxx> wrote:
>
> 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
> To: amibroker@xxxxxxxxxxxxxxx
> 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
*********************************
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|