AFL Tools

Automatic technical analysis


Since version 2.5 AmiBroker features automatic technical analysis tools. AmiBroker can check for user defined buy/sell conditions giving you an idea about the current situation on the market. It can also perform a system test (simulation) telling you about the performance of your trading system. Version 3.0 of AmiBroker introduced new formula language (AFL) allowing you to write not only system tests but also custom indicators and guru advisor commentaries.

In order to do this you have to define buy and sell rules, indicator formulas or commentaries using a special AmiBroker Formula Language (AFL), which is described below. For more information about using analysis tools see also the description of the Automatic analysis window, Formula Editor, and Commentary window in Chapter 2.

AmiBroker Formula Language

AFL is used for defining your trading rules and explorations in Automatic analysis window, custom commentaries in the Guru Commentary window and indicator formulas in Formula Editor window.

Detailed reference of AFL language is given here.


Below you will find some simple buy and sell rules. They are just formal equivalents of some of the most common indicators’ interpretation rules. You can treat them as a starting point for developing your own trading strategies, but before you get too excited when you think you've found the "holy grail" of trading systems, check the following:

buy = cross( macd(), 0 );
sell = cross( 0, macd() );

buy = cross( ema( close, 9 ), ema( close, 15 ) );
sell = cross( ema( close, 15 ), ema( close, 9 ) );

buy = cross( rsi(), 30 );
sell = cross( 70, rsi() );

buy = cross( ultimate(), 50 );
sell = cross( 50, ultimate() );

Automatic analysis window

Automatic analysis window enables you to check your quotations against defined buy/sell rules. AmiBroker can produce report telling you if buy/sell signals occurred on given symbol in the specified period of time. It can also simulate trading, giving you an idea about performance of your system.

In the upper part of window you can see text entry field. In this field you should enter buy and sell rules. These rules are assignment statements written in AmiBroker's own language. You can find the description of this language in AFL reference guide.

In order to make things work you should write two assignment statements (one for buy rule, second for the sell rule), for example:

buy = cross( macd(), 0 );
sell = cross( 0, macd() );

Automatic analysis window allows you also to optimize your trading system and perform in-depth explorations

See also: detailed description of Automatic Analysis window controls

Formula Editor

Formula Editor allows you to write formulas to be used as indicators or in Automatic Analysis window. More on this

Guru Advisor Commentary window

Commentary window enables you to view textual descriptions of actual technical situation on given market.
Commentaries are generated using formulas written in AmiBroker's own formula language. You can find the description of this language in AmiBroker Formula Language Reference Guide.

Moreover Commentary feature gives you also graphical representation of buy & sell signals by placing the marks (arrows) on the price chart.

NOTE: Using complex commentary formulas you may observe long execution times.

See also: detailed description of Guru Advisor Commentary window controls