Please help me with a custom backtest question


I going crazy here trying to produce equity curves for each optimization run. I've come to the conclusion that it´s probably not possible. At least not the way I'm trying. Can anyone confirm if this code should produce 3 different equity curves?

ver = optimize("version", 1, 1, 3, 1);


if( Status("ActionEx") == actionExOptimizePortfolio )
	Eq = Foreign("~~~EQUITY", "C");
	AddToComposite( Eq, "~~~EQUITY_"+ver, "C", atcFlagDeleteValues |  atcFlagEnableInBacktest | atcFlagEnableInPortfolio); 

if( Status("action") == actionPortfolio )
	bo = GetBacktesterObject();

Big thanks in advance!

The correct way to implement this is using only "Status("action") == actionPortfolio" and "bo.EquityArray" instead of "~~~EQUITY". Then it works fine!

More information here: AmiBroker Knowledge Base » How to create copy of portfolio equity?

1 Like

Yes, the Knowledge Base shows how to do that. It is important to remember that optimization is just a series of backtests. If you have custom backtester code it will run in both "Backtest" and "Optimization" modes the same way. Therefore any CBT technique used for backtest, works in optimization too.