2 registered members (Ayumi, 1 invisible),
584
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Issue with inconsistent test results
#473789
08/15/18 10:27
08/15/18 10:27
|
Joined: Jan 2017
Posts: 95 Bulgaria
kvm
OP
Junior Member
|
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)
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,731 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,731
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
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2017
Posts: 95
Bulgaria
|
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,731 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,731
Chicago
|
I get the same performance both ways if I modify the code as follows.
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
OP
Junior Member
|
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:
function run() {
LookBack = 500;
asset("EUR/USD");
StartDate = 2010;
EndDate = 2015;
...
}
gives a totally different (worse) result comparing to this:
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,731 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,731
Chicago
|
I fixed my code above. According to the asset() page: 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.htmIt'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.
|
|
|
|