Using Batch window


The Batch window introduced in version 6.20 (first time actually in 6.17.0 BETA) allows the user to automate mundane repetitive tasks by providing batch processing.

Now the user can easily define and automatically run sequences of Analysis operations such as scan, exploration, backtest and optimization and file export. Previously such automation was available only for programmers by means of OLE automation. Now it is available to everyone via easy-to-use interface.

Generally a batch consists of any number of following basic operations:

User interface

You can open New Analysis window in a number of ways:

  1. click on the New Tab (+) button and selecting New Batch

  2. File -> New -> New Batch menu

The user interface for Batch window is very simple:

Basic operations

Adding/inserting new batch step

You can add a new batch step by clicking on the Insert button. It will add a new step at the end if nothing was selected prior to clicking, or it will insert a new step before previously selected step. You can also add a new step if you just double click on the list past the last listed step.

If you add/insert new step the Edit batch step window will appear (see below).

Editing existing batch step

To edit existing item double click on it, or use Edit button. The Edit batch step will appear allowing you to define batch step action and parameters:

In this window you can select an action to be performed using Action combo-box and enter the Parameter or File name to be used for given action.

Actions like Load Project, Export to File or Play sound (.wav) need a file name to be entered / picked via (...) button. Actions like Set Current Symbol or Say need a text parameter (symbol or text to be spoken) to be entered. Other actions (like Scan, Backtest, ...) do not need any extra parameters. When selected action does not require parameter, the second entry field (Parameter/File) is hidden.

Once you select desired action along with parameters press OK to accept this step. If you changed your mind press Cancel. If you cancel Insert operation, newly inserted item will be removed from the list.

Deleting existing batch step

To delete existing batch step, select it by clicking on the list and press Delete button.

Moving / re-arranging batch steps

You can change the sequence of existing steps by moving individual items up and down. To move item up or down please click on it once and use blue up and down arrow buttons in the toolbar. You can also re-arrange items by dragging them. To do so, click on item(s) once (to multi-select use CTRL or SHIFT key), and then pressing and holding down the left mouse button drag them to desired location.

Running batch

Once all batch steps are defined you can run the sequence by pressing Run (green arrow) button in the toolbar. All steps will be executed in the sequence, you will see subsequent items' status changing to "In progress...", then to "Completed" or "Failed". If any steps ends up with "Failed" status, entire batch execution is stopped.

To temporarily pause execution of batch press Pause button. To abort execution of running batch press Stop button. (Those buttons are only active when batch is running, otherwise they are disabled/grayed).

Saving batch for future use

A batch sequence can be saved using File->Save / File->Save As... into .abb file (stands for AmiBroker Batch).

Once batch is saved it can be later loaded back using File->Open or using File->Recent Files menu.

Miscellaneous commands

Running external programs from batch

A batch command Execute And Wait allows to execute external program and wait for its completion (allows among other things launching AmiQuote download and waiting until it is complete)

The following example launches AmiQuote, loads "YourTickerList.tls", performs download and closes AmiQuote:

ExecuteAndWait amiquote\quote.exe YourTickerList.tls /download /close

Running data plugin commands

Some data vendors may provide special data-specific commands that can be run from the batch. For example PremiumData will provide database maintenance capability.

To run data plugin command use

DataPluginCmd commandname

Where commandname is data-vendor specific command. Please consult data vendor for details. If you specify non-existing command the status of operation will be "Failed" and batch execution will stop.

Importing quotation data from ASCII files

DataImportASCII command allows to automate imports via batch. The parameter is file name to be imported. The importer uses file extension to determine format file used, so if you are importing File.aqh then aqh.format definition file will be used automatically. Import would fail if corresponding definition file does not exist in the "Formats" subdirectory.

Triggering batch run programmatically from AFL level

It is possible to start the batch programmatically from AFL. The ShellExecute function in AmiBroker 6.20 supports "runbatch" command.

if( ParamTrigger("batch", "run me" ) )
    ShellExecute("runbatch", "", "" );

Please note that this is asynchronous call, i.e. ShellExecute would start a batch and return immediately even though batch may (and usually will be) still running, so it is "fire and forget" kind of operation. Be careful as repeated executions of AFL would trigger repeated batch runs. After running batch batch and analysis windows that were opened by batch are automatically closed.


Batches can be scheduled for automated run on certain time or at the application start-up. To open batch Scheduler either click on Scheduler icon (clock) in the Batch toolbar or use Tools->Scheduler item from the main application menu.

This will open the Scheduler window

In the Scheduler window's toolbar you can see the icons to: Add, Delete, and Edit tasks and to decide whenever to close batch window on completion.

The list displays the path to the batch file, Start date/time and Repeat interval and the date/time of Next run. If batch is scheduled to be run on startup then Next run field will be empty.

To add a task, click Add task icon. This will open the following dialog:

To definine scheduled run of batch please do the following:

  1. Pick a batch file to be run (with .ABB extension). Such file can be created by simply saving an open Batch via File->Save / File->Save As. If you opened scheduler from already open batch window, current file will be automatically selected for you.
  2. Define when to run the batch: either at application start or at specific date/time
  3. Define if runs should be repeated at certain intervals or not. Runs can be done daily or hourly on specific week days and specific time range

Once you are done click OK and you will see scheduled task in the Scheduler window list.