Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (Quad, AndrewAMD, EternallyCurious, 7th_zorro), 511 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Issue with inconsistent test results #473789
08/15/18 10:27
08/15/18 10:27
Joined: Jan 2017
Posts: 95
Bulgaria
kvm Offline OP
Junior Member
kvm  Offline OP
Junior Member

Joined: Jan 2017
Posts: 95
Bulgaria
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");
}


Re: Issue with inconsistent test results [Re: kvm] #473790
08/15/18 12:33
08/15/18 12:33
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
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.

Last edited by AndrewAMD; 08/15/18 15:33.
Re: Issue with inconsistent test results [Re: AndrewAMD] #473791
08/15/18 13:30
08/15/18 13:30
Joined: Jan 2017
Posts: 95
Bulgaria
kvm Offline OP
Junior Member
kvm  Offline OP
Junior Member

Joined: Jan 2017
Posts: 95
Bulgaria
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.

Re: Issue with inconsistent test results [Re: kvm] #473792
08/15/18 14:30
08/15/18 14:30
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
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();

}


Last edited by AndrewAMD; 08/15/18 15:10. Reason: See remarks below.
Re: Issue with inconsistent test results [Re: AndrewAMD] #473793
08/15/18 15:05
08/15/18 15:05
Joined: Jan 2017
Posts: 95
Bulgaria
kvm Offline OP
Junior Member
kvm  Offline OP
Junior Member

Joined: Jan 2017
Posts: 95
Bulgaria
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");
  ...
}


Re: Issue with inconsistent test results [Re: kvm] #473794
08/15/18 15:13
08/15/18 15:13
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
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.

Re: Issue with inconsistent test results [Re: AndrewAMD] #473795
08/15/18 15:24
08/15/18 15:24
Joined: Jan 2017
Posts: 95
Bulgaria
kvm Offline OP
Junior Member
kvm  Offline OP
Junior Member

Joined: Jan 2017
Posts: 95
Bulgaria
I think everything is clear now, especially the asset() tip. Thank you for responding that quickly.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1