Error 042 with simple 2 algo strategy

Posted By: GPEngine

Error 042 with simple 2 algo strategy - 07/26/14 21:55

The following simple (and pointless) script results in this error message:
Error 042: EUR/AUD:B parameters not found!
or
Error 042: EUR/AUD:A parameters not found!
Code:
function run() {
  set(TESTNOW+PLOTNOW);
  set(PARAMETERS);
  NumYears = 1;
  LookBack = 334;
  asset("EUR/AUD");

  algo("A");
  var p1 = optimize(150, 1, 333, -33);
  algo("B");
  var p2 = optimize(150, 1, 333, -33);
}


Why? What am I missing?
Posted By: GPEngine

Re: Error 042 with simple 2 algo strategy - 07/26/14 22:00

You might think it is because there are no trades in A and B. But the error also happens when I inject (random) trades.
Code:
function junk(var p1) {
  vars P = series(random());
  vars Osc = series(WMA(P, p1));
  if (valley(Osc)) {
    exitShort();
    enterLong();
  }
  if (peak(Osc)) {
    exitLong();
    enterShort();
  }
}

function run() {
  set(TESTNOW+PLOTNOW);
  set(PARAMETERS);
  NumYears = 1;
  LookBack = 334;
  asset("EUR/AUD");

  if (random() > 0) {
    algo("A");
    var p1 = optimize(150, 1, 333, -33);
    junk(p1);
  } else {
    algo("B");
    var p2 = optimize(150, 1, 333, -33);
    junk(p2);
  }
}

Posted By: jcl

Re: Error 042 with simple 2 algo strategy - 07/28/14 07:20

In a portfolio system, all optimize calls must be inside a loop(). This would be the correct code:

Code:
while(algo=loop("A","B"))
  var p1 = optimize(150, 1, 333, -33);

© 2024 lite-C Forums