Australian (ASX) Stock Market Forum

Document - AmiBroker's Custom Backtester Interface

GreatPig

Pigs In Space
Joined
Jul 9, 2004
Posts
2,368
Reactions
10
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

GreatPig

Pigs In Space
Joined
Jul 9, 2004
Posts
2,368
Reactions
10
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

theasxgorilla

Problem solved... next bubble.
Joined
Dec 7, 2006
Posts
2,343
Reactions
1
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.
 

theasxgorilla

Problem solved... next bubble.
Joined
Dec 7, 2006
Posts
2,343
Reactions
1
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.
 

GreatPig

Pigs In Space
Joined
Jul 9, 2004
Posts
2,368
Reactions
10
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
 

GreatPig

Pigs In Space
Joined
Jul 9, 2004
Posts
2,368
Reactions
10
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

GreatPig

Pigs In Space
Joined
Jul 9, 2004
Posts
2,368
Reactions
10
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
 
Joined
Mar 9, 2010
Posts
81
Reactions
3
I know its old but what a great help.
Saved me a day of searching!
Thanks a lot.
 
Joined
Jun 30, 2007
Posts
6,175
Reactions
615
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