Issue with inconsistent test results

Posted By: kvm

Issue with inconsistent test results - 08/15/18 10:27

Hi all,

I'm playing around with the Zorro's script language and couldn't explain to myself what is going on. If I introduce a single line defining unused series variable, the test result changes from:

Annual 54% 631p to Annual +44.9% +525.3p

Is this a bug or I'm doing something totally wrong?
Test Environment: Zorro 1.83.2 / Windows 7 (32 bit)
Code:
function run() {
  vars Price = series(price());
  vars Trend = series(LowPass(Price,500));
	
  // ISSUE: uncommenting the line below gives a different test result!
  //vars MMI_Raw = series(MMI(Price,300));

  Stop = 4*ATR(100);
	
  if(valley(Trend))
    enterLong();
  else if(peak(Trend))
    enterShort();

  StartDate = 2010;
  EndDate = 2015;
  asset("EUR/USD");
}

Posted By: AndrewAMD

Re: Issue with inconsistent test results - 08/15/18 12:33

Why are you calling asset() *after* you enter trades? You're supposed to call it before you even define a series.

Otherwise, you are trading the current asset in your window drop-down. Thus, you have introduced a confounding variable.
Posted By: kvm

Re: Issue with inconsistent test results - 08/15/18 13:30

Originally Posted By: AndrewAMD
Why are you calling asset() *after* you enter trades? You're supposed to call it before you even define a series.

Otherwise, you are trading the current asset in your window drop-down. Thus, you have introduced a confounding variable.


I think there are no such restrictions, you can place it anywhere, as long as it is after StartDate and EndDate.

Actually, the script is Alice1a.c from Book Scripts link, so I guess it is correctly written.
Posted By: AndrewAMD

Re: Issue with inconsistent test results - 08/15/18 14:30

I get the same performance both ways if I modify the code as follows.

Code:
function run() {
  LookBack = 500;
  StartDate = 2010;
  EndDate = 2015;
  asset("EUR/USD");

  vars Price = series(price());
  vars Trend = series(LowPass(Price,500));
	
  // ISSUE: uncommenting the line below gives a different test result!
  //vars MMI_Raw = series(MMI(Price,300));

  Stop = 4*ATR(100);
	
  if(valley(Trend))
    enterLong();
  else if(peak(Trend))
    enterShort();

}

Posted By: kvm

Re: Issue with inconsistent test results - 08/15/18 15:05

Yes, I confirm that. Explicitly setting the LookBack to a hard coded value seems to fix the issue. Thanks.

But I still can't understand why I have to call *asset()* before setting the StartDate and EndDate variables?

Because this:
Code:
function run() {
  LookBack = 500;
  asset("EUR/USD");
  StartDate = 2010;
  EndDate = 2015;
  ...
}


gives a totally different (worse) result comparing to this:
Code:
function run() {
  LookBack = 500;
  StartDate = 2010;
  EndDate = 2015;
  asset("EUR/USD");
  ...
}

Posted By: AndrewAMD

Re: Issue with inconsistent test results - 08/15/18 15:13

I fixed my code above.

According to the asset() page:
Quote:
If the asset function is used, it must be called in the first run (INITRUN) of the script. All variables and flags that affect the price data array, such as BarPeriod, BarZone, LookBack, Detrend, StartDate, EndDate, TICKS, Weekend, UpdateDays, AssetList, History etc. must be set _before_ calling asset.
http://zorro-project.com/manual/en/asset.htm

It's good practice to define an asset() before the series because if you trade multiple assets with the same script, it will become a requirement.
Posted By: kvm

Re: Issue with inconsistent test results - 08/15/18 15:24

I think everything is clear now, especially the asset() tip. Thank you for responding that quickly.
© 2024 lite-C Forums