Issue 10/2001 (No. 18)
AmiBroker Tips newsletter.
Issue 10/2001. No 18.
5 May 2001.
Copyright (C)2001 Tomasz Janeczko.
All back issues available from:
http://www.amibroker.com/newsletter/
IN THIS ISSUE
1 Welcome
2 Tutorial: Working with chart sheets
3 AFL Library: How to create your own exploration
1 Welcome

Welcome to the 10th issue of AmiBroker Tips newsletter in the 2001. This time I will show you how to use the latest additions to AmiBroker (available in version 3.58 beta - http://www.amibroker.com/bin/ab358beta.zip) - multiple chart sheets and layouts and exploration facility added to Automatic Analysis window

Just a reminder: if you have any comments/suggestions or article ideas, please don't hesitate to drop a line to newsletter@amibroker.com

2 Tutorial: Working with chart sheets

AmiBroker 3.58 introduces multiple chart sheets and loading/saving layouts. This feature enables you to quickly switch between different indicator sets saving your time dramatically.

A chart sheet is a set of chart panes (with indicators) displayed within single frame.

You can switch between different sheets by clicking on the tabs located in the bottom of AmiBroker window as show in the following picture:

You can change the name of the tab by clicking on it with RIGHT mouse button, so the following window appears:

You can change all four tab names (one by one) so they are more descriptive (and they relate to the contents of the sheet):

The next step is to set up your sheets according to your personal preference. Just add/remove chart panes to/from each sheet. This way you can have 4 different indicator sets that you can recall very quickly by switching to appropriate tab.

Now, if you want to make your setup permantent just right-click on the chart and select the following menu item (Layout->Save as default):

Note that by default the layout is saved automatically when AmiBroker is closed (unless you change preferences settings accordingly)

The last feature to describe is the ability to Save the layout to the disk file (with your own name) so it can be read back later. The Layout->Save and Layout->Load menu items are provided for that purpose. Note that this way you can maintain unlimited number of predefined layouts saved on your disk (in addition to the default one loaded at startup) and quickly switch to the one you need at the moment by just loading it off disk.

3 AFL Library: How to create your own exploration

AmiBroker 3.58 brings a new feature to Automatic Analysis window called "Exploration". Basically, an exploration works in a similar way to scan but instead of looking for and reporting just buy/sell signals it allows you to generate customizable screening (or exploration) report that can give you much more information than simple scan.

The idea behind an exploration is simple - one variable called filter controls which stocks/quotes are accepted. If "true" (or 1) is assigned to that variable for given stock/quote it will be displayed in the report.

So, for example, the following formula will accept all stocks with closing prices greater than 50 :

filter = close > 50;

Note that exploration uses all range and filter settings that are also used by back-tester and scanning modes so you can get multiple signals (report lines) if you select "All quotations" range. To check just the most recent quote you should choose "n last quotations" and "n=1" as shown here:

Now, what about customizable reports?

Yes, exploration mode allows you to create and then export a report with completely customizable columns and it is quite simple to do.

First you must tell AmiBroker how many custom columns you want to have. Note that first two columns: ticker and date are predefined and they can not be changed. So if you want only one custom column - closing price - you will need to write:

numcolumns = 1;
column0 = close;

As you can see all you need to do is assign a value to numcolumns variable - this should be the number of your own columns (excluding predefined ticker and date columns) and assign the column value to the variable columnN (where N=0,1,..... is zero-based column index (or number))

If you now press "Explore" button in Automatic Analysis window you will get the result similar to this:

Note that there are actually 3 columns: predefined Ticker and Date column and one custom column 0 holding close price. Note that only tickers with close price greater than 50 are reported.

Now you can click "Export" and your exploration will be saved to CSV (comma separated values) file that could be easily loaded to any other program including Excel for further analysis.

In addition to required filter, numcolumns, columnN exploration mode uses two optional variables for customizing the display.

ColumnNname (where N is column index) variable allows you to define the header name. So, in our previous example, assigning

column0name = "Close";

Will change the name of the first custom column from the default "Column 0" to more appropriate "Close".

ColumnNformat (where N is column index) variable allows you to define the formatting applied to numbers. By default all variables are displayed with 2 decimal digits, but you can change this by assigning a different value to this variable: 1.5 gives 5 decimal digits, 1.0 gives no decimal digits. So, in our example, typing:

column0format = 1.4;

will give closing prices displayed with 4 decimal digits.
(Note for advanced users: the integer part of this number can be used to pad formatted number with spaces - 6.0 will give no decimal digits but a number space-padded upto 6 characters.)

Examples

The exploration mode is extermely flexible: you can, for example, export the whole database to CSV file using the following formula:

filter = 1; /* all stocks and quotes accepted */
numcolumns = 5;
column0 = open;
column1 = high;
column2 = low;
column3 = close;
column4 = volume;
column0name = "open";
column1name = "high";
column2name = "low";
column3name = "close";
column4name = "volume";
column0format = 1.4;
column1format = 1.4;
column2format = 1.4;
column3format = 1.4;
column4format = 1.0;

This one will show you only heavily traded stocks:

filter = volume > 5000000; /* adjust this threshold for your own needs */
numcolumns = 2;
column0 = close;
column1 = volume;

or...just show stocks with volume being 30% above its 40-day exponential average

filter = volume > 1.3 * ema( volume, 40 );
numcolumns = 2;
column0 = close;
column1 = volume;

With this one, you can export multiple indicator values for further analysis:

filter = close > ma( close, 20 ); /* only stocks trading above its 20 day MA*/
numcolumns = 10;
column0 = macd();
column1 = signal();
column2 = adx();
column3 = rsi();
column4 = roc( close, 15 );
column5 = mfi();
column6 = obv();
column7 = cci();
column8 = ultimate();
column9 = trix();

Final tip

Please don't forget that you can sort the results of the exploration by any column by simply clicking on its header.

.... and that's all for this week - hope you enjoyed reading


AmiBroker Tips newsletter. Issue 10/2001. Copyright (C)2001 Tomasz Janeczko. All back issues available from: http://www.amibroker.com/newsletter/