Looping of custom backest

hey guys…
is there a way of executing custom backetest again and again in a loop with each loop providing different results based on different inputs provided to each.

currently I am trying to use actionportfolio in a loop of custom backtest with different set of inputs to each loop and then writing every result file , but all result file are same , I am not getting expected output. in fact all output file has the result of last loop.

You could let Amibroker do the looping for you. Use the optimizer. The custom backtest code will be executed once for each set of optimization parameters.

2 Likes

thanks for replying…
but the problem is that those parameters can’t be used as optimization parameters as they are different dates

You’re mistaken. Everything can be run as optimization. Optimization is JUST A LOOP. Nothing more. The meaning to the loop counter is UP TO YOU.

counter = Optimize("counter", 0, 0, 100, 1 );

switch( counter )
{
  case 0:       date_param = "2014-01-02"; break;
  case 1:       date_param = "2017-03-05"; break;
  case 2:       date_param = "2013-05-02"; break;
.... and so on
}

In switch statement you can assign whatever meaning you wish. You can run optimization on tastes of coffee if you wish.

@Steve’s answer is correct one. It is the only correct way to do what you are trying to do. Custom backtest code can only be called once per backtest. Calling it in a loop won’t work because backtest is one-way process - it processes the signals and once signals are processed they can’t be used again. Running optimization is correct way to do “looping” in custom backtest. So just follow @Steve’s advice

ok
thanks guyzz
I will surely give it a try.