How to create copy of portfolio equity?

As you know Portfolio backtester creates special ticker “~~~EQUITY” which holds portfolio-level equity of the system under test. Some may find it useful to save this equity into another symbol after backtest for future analysis and/or comparison. Good news is that it is possible to do that automatically using custom backtester procedure and AddToComposite function. The formula below shows how.

// YOUR TRADING SYSTEM HERE

SetCustomBacktestProc("");

if( Status("action") == actionPortfolio )
{
 
bo GetBacktesterObject();
 
bo.Backtest();
 
AddToCompositeForeign("~~~EQUITY","C"), 
                 
"~~~MY_EQUITY_COPY""X"
                 
atcFlagDeleteValues atcFlagEnableInPortfolio );
}

Please note that prior to version 4.78.1 BETA, atcFlagEnableInPortfolio did not work in combination with atcFlagCompositeGroup (or atcFlagDefaults) so we needed to avoid this flag in the code above, to make it work fine with previous versions of AmiBroker. In version 4.78.1 it works with all combinations of flags, so you don’t need to worry about this any more.

3 Responses to “How to create copy of portfolio equity?”

  1. Bo Ek
    December 30th, 2006 | 10:11 am

    How do you watch your real equity curve? I mean after manually putting in real life
    buy/sell and deposit/withdraw actions. Is it possible to just plot the equity curve
    without any backtesting or similar?

  2. January 1st, 2007 | 8:01 am

    Yes it is possible, this article shows how to do that: http://www.amibroker.com/kb/2006/05/06/discretionary-equity/

  3. Herman
    April 7th, 2007 | 12:31 am

    I can’t get it to work TJ, I tried running this code in the AA Portfolio Tester:

    Buy=Sell=Short=Cover=0;
    if( Status(”action”) == actionPortfolio ) _TRACE(”# actionPortfolio test”);

    DBV Shows no output, also “actionPortfolio” is not documented in the Help.

Leave a reply