Performance tests


To be finished...

Three AFL scripts that employ loops were picked from the AFL Library. The full code and the loop code of these AFL scripts were converted into .NET plugins. So the very same "trading logic" was implemented in three forms for the comparision tests:

1. As they were downloaded from the AFL library.

2. They got converted to a fully .NET AFL plugin (all code got converted).

3. They got converted to an AFL + .NET plugin solution where only the code that employ the loop were converted to compiled .NET plugin.


To be finished...

1. Compiled .NET loops have significant (>10x) performance advantage over AFL script loops (see Test case 1).

2. In real life trading systems the code logic consists of loops and other array operations that are handled by built-in AmiBroker functions or by .NET for AmiBroker array operators (see Test case 2 and Test case 3). Converting the loops alone can give a 20-50% time saving in total backtesting time. Converting whole AFL scripts may (Test case 2, ~1.5x vs. ~2x performance) or may not (Test case 3, ~1.4 vs. 1.5x performance) justify the investment of conversion. If the script consists of a lot of array operations (addition, multiplication, comparision, etc), its performance can be greatly improved by conversion.

Test method

To be finished...

Test Results

The below tables and screen shots show the results of perfromance tests at different number of used bars while using the original and the converted solutions.

Test case 1 : Signal to Noise

Original AFL:

This AFL's logic consists of a single loop of all bars. The loop's body has complex calculations that use many arrays. Almost no other code can be found in the AFL file so it is a good candidate to show how AFL and .NET loops' performance compare.

Test case 2 : Automatic Trendlines using Multiple Timeframes

Original AFL:

Test case 3 : Automatic Linear Trend Channel 2

Original AFL:

This AFL script is rewritten to a mixed version (only the loop is converted to .NET) and to a .NET version (all code, including all calculations and plots are done in .NET)

The loop of bars is not too complex. Converting the loop gives the base of the performance advantage (~2X speed up). Converting the rest of the code does not improve performance significantly.