Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zorro compiling and running #425173
06/28/13 12:55
06/28/13 12:55
Joined: Nov 2012
Posts: 126
B
blaub4r Offline OP
Member
blaub4r  Offline OP
Member
B

Joined: Nov 2012
Posts: 126
In Backtests, Zorro seems to differentiate between compiling (and running the script) and just running the script. The latter just calls the run function and ignores everything else, which can cause problems when using global variables.
As an example:
// ---------------------------------------------------
int zaehler = 0;

function run()
{
StartDate = 20090520;
EndDate = 20120501;
zaehler++;

plot("asdf",zaehler,0,BLACK);

PlotWidth = 800;
PlotHeight1 = 320;
}
// -----------------------------------
With every subsequent run of this script zaehler is not reinitialised as 0 but keeps the value of the previous run, which is kind of strange for a Backtest.
My questions are:
1) How does this affect real trading?
and
2) Is there a way to code the example in a way it works properly on every run?

Re: Zorro compiling and running [Re: blaub4r] #425174
06/28/13 13:24
06/28/13 13:24
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
It is not only compiling and running - when you optimize and test a system, it can run through many cycles, dependin on your test method. You must initialize global and static variables at every cycle start.

The right way to do it is

if(is(INITRUN)) zaehler = 0;

Re: Zorro compiling and running [Re: jcl] #425181
06/28/13 14:02
06/28/13 14:02
Joined: Nov 2012
Posts: 126
B
blaub4r Offline OP
Member
blaub4r  Offline OP
Member
B

Joined: Nov 2012
Posts: 126
Thank you, I will adapt my scripts.
I think it's still strange for a Backtest as I would expect the second run to lead to the same results as the first one.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1