Quantcast
Channel: AFL – AmiBroker Knowledge Base
Browsing all 56 articles
Browse latest View live

How to synchronize backtesting setup on different computers

When comparing the output of back-tests obtained from different working machines, it is necessary to make sure that all aspects of our testing are identical, including: the database the formula used...

View Article


How to restrict trading to certain hours of the day

In order to include time-based conditions in the back-testing code – we can use TimeNum() function to check the time-stamp of given bar and use it as input for any time-based conditions....

View Article


Image may be NSFW.
Clik here to view.

New keywords in AFL and possible conflict with user-defined variables

AmiBroker 4.91.0 BETA introduced the following new keywords: switch, case, break, continue, default You have to make sure that your formulas do not use them as variable names. The above words are now...

View Article

Image may be NSFW.
Clik here to view.

QuickAFL facts

QuickAFL(tm) is a feature that allows faster AFL calculation under certain conditions. Initially (since 2003) it was available for indicators only, as of version 5.14+ it is available in Automatic...

View Article

AFL execution speed

NOTE: Benchmarks and timings given below are little outdated because article was written back in 2008. Today’s CPUs are faster and memory bandwidth is also higher. AmiBroker Formula Language (AFL)...

View Article


About floating point arithmetic

In general, to represent numbers with fractional parts, computers use a “floating point” binary representation. Floating point arithmetic is also used by AmiBroker for AFL calculations. For some more...

View Article

A function with multiple return values

A typical AFL function returns one value. For example sin( x ) returns sine value of argument x. Sometimes however it is useful and/or required to return more than one value from the function....

View Article

Do NOT make assumptions on number of bars

From time to time some users face “Error 10. Subscript out of range” in their formulas. The error itself is described in the manual, but still a few words of explanation why it happens may be useful....

View Article


Can I encrypt my formula so no-one can decipher it?

Currently the only way to protect your code from other peoples’ eyes is to translate part of the formula (such as few functions) or entire formula to C/C++ language and compile as AFL plugin DLL. Doing...

View Article


What are constants in AFL and how they work

The AFL language contains many pre-defined words like: shapeUpArrow, stopTypeTrailing, colorRed, styleThick, inDaily and many more. These are examples of constants. As written in AFL language...

View Article

When and how often AFL code is executed?

All analysis in AmiBroker including charting, Analysis window or commentaries is based on underlying AFL code, which is being executed by the program to produce the required output. Therefore – any...

View Article

Image may be NSFW.
Clik here to view.

Checking relationship between multiple moving averages

When we compare the positions of several lines against one another, we need to remember about using correct operators, so our AFL statement return correct results. Let us consider a set of moving...

View Article

How to populate Matrix from a text file

AmiBroker 6.00 has introduced support for matrices. After we create a matrics with Matrix function call: my_var_name = Matrix( rows, cols, initvalue); then in order to access matrix elements, we need...

View Article


Image may be NSFW.
Clik here to view.

How to fix Error 61 in printf/StrFormat calls

AmiBroker version 6.07 has introduced a strict check for correct string formatting in printf and StrFormat functions. These functions allow to specify the string followed by the list of arguments that...

View Article

Image may be NSFW.
Clik here to view.

How to count symbols in given category

When we want to find out how many symbols belong to given category (such as watchlist) then for manual inspection, it is enough to hover the mouse cursor over the particular category name in the...

View Article


Image may be NSFW.
Clik here to view.

Calling custom user functions in our code

AFL language allows us to define reusable functions that can be used in our formulas. The following chapter of the manual explains the procedure in details:...

View Article
Browsing all 56 articles
Browse latest View live