Australian (ASX) Stock Market Forum

Document - AmiBroker's Custom Backtester Interface

GreatPig

Pigs In Space
Joined
9 July 2004
Posts
2,368
Reactions
14
Attached is a document I've written covering use of the AmiBroker custom backtester interface. It covers the interface's object model, and the high-level, mid-level, and low-level backtester interfaces, with examples of the use of each. There's also an appendix on using DebugView to debug AFL code.

As the custom backtester interface relies heavily on looping, except for the high-level interface, this document is aimed at AFL programmers who are already comfortable with standard AFL, arrays, indexing, and looping. If you don't understand looping, it's highly unlikely that you'll be able to understand use of the mid-level and low-level backtester interfaces. You may be able to use the high-level interface without a knowledge of looping though.

This document may be freely distributed. It's also been uploaded to the AmiBroker Yahoo forum files area.

Cheers,
GP
 

Attachments

  • AmiBroker Custom Backtester Interface.pdf
    417.5 KB · Views: 279
Updated to version 2 to fix a few errors. Main change relates the the mid-level example using the volume EMA array, where it needs to be passed from the main AFL code using the AddToComposite function.

Cheers,
GP
 

Attachments

  • AmiBroker Custom Backtester Interface.pdf
    419 KB · Views: 143
Brilliant document GP! Also got your one on looping. I haven't coded for about 10 years, so its going to come is uber handy as a refresher of sorts.
 
In AFL I keep tripping myself up on the IF and IIFs!

I'll write wonderful code and then find that in half a dozen places I have to go and rewrite IFs into IIFs...and nested IIFs are not as neat and intuitive to construct.
 
Thanks AG.

Don't worry about the IF/IIF thing, I still do that all the time too. With the way numbers and arrays can look identical, it's very easy to temporarily forget when writing something like "if (myvar > 10)" whether myvar is an array or a number.

Cheers,
GP
 
I've attached and uploaded another version of the document to the Yahoo forum files area with a few more examples. Specifically, I've added a couple of small examples to the high-level interface section to demonstrate adding metrics to the Trade objects, and also added another appendix with a more complex example implementing the Lichello AIM algorithm using the low-level interface.

Cheers,
GP
 

Attachments

  • AmiBroker Custom Backtester Interface.pdf
    447.8 KB · Views: 213
I've uploaded another version of the document to the Yahoo forum files section to fix the mid-level example using the AddToComposite function.

It seems that to use this function in backtests, the "atcFlagEnableInBacktest" flag needs to be added to the defaults:

Code:
AddToComposite(EMA(Volume, 100), "~evol_"+Name(), "V",
                        atcFlagDefaults | atcFlagEnableInBacktest);

I'm a little confused with this though, as sometimes it seems to work without that flag and sometimes not.

GP
 
Great Pig made so many useful contributions.

Seems like quite a while since he has been around. Would like to shoot him a few questions on this stuff.
 
Top