Which property in CBT that I can write my own information?


Now I’m trying to code Amibroker in Custom Backtester Interface mode. After I’ve read pdf file, I found that the property in trade object that I can write my own information is MarginLoan.

So my question is "Is amibroker have another empty object in Custom Backtester Interface mode that I can assign my own information or it just have only Marginloan property? "

Thank you very much.

No you can’t use MarginLoan to store your own data. If you need custom data in CBT use static variables

This example shows how to pass any value from first pass to CBT:

1 Like

Hello Mr. Tomasz,

Will appreciate it very much if you please guide about the ideal place to remove the StaticVariable
"StaticVarSet( Name() + “ATR”, ATR( 15 ) )" in your example.

So that unnecessary resources are not used. (May be - you may want to update the example).


Sanjiv Bansal

I spent the past few days working with custom metrics for the first time. They allow you to insert values into your Backtest Trade Report for each and every trade!.

The example Tomasz provides above works perfectly. Set up a sandbox.afl and copy and run the sample code.

I believe you can replace “ATR” with whatever “Column Heading” you like, and ATR(15) with just about any calculation you like. If you haven’t already, I suggest you read up on how Static Variables work.

One tidbit I found somewhat burried in the documentation is that each static variable contains timestamps automatically added. Using trade.entrydate you can retrieve the static variables value at that exact point in time.

Perhaps someone else can better explain or provide a link that explains the contents of static variables.

Thanks you very much for your support.Now I can access the value from the first pass like ATR MACD and much more. ^^

Like @SwingTradeMonkey, I am stuying Custom Backtester Interface for the first time now (for this reason I am cheking this topic trying to get new information about it). I have found next article which could help you (http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/).