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
1 registered members (AndrewAMD), 559 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 7 1 2 3 4 5 6 7
Re: New Zorro version 2.40.2 [Re: jcl] #483842
08/02/21 08:34
08/02/21 08:34
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Some comments:

- Wrong month: Maybe it's some setting of your script? Find out with a simple script like this:

void tock() { printf("\n%02d",month()); }
void run() { asset("EUR/USD"); }

Then add your settings at the begin of the run function until the month becomes wrong again. Please let us know what it was.

- Too many errors 047: Yes, this will be limited to 2 or 3 errors.

- SR is 0 with 2.40.2: Please post or send that script.

Re: New Zorro version 2.40.2 [Re: jcl] #483844
08/03/21 00:49
08/03/21 00:49
Joined: May 2018
Posts: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
hi jcl,

It looks like the problem is not the month() function, but rather the month(1) offset at the 1st bar of a new month.

As you can see from the log snippet below, the first bar on 21-02-01 shows: month(0)=2 and month(1)=2.

You agree that it should be: month(0)=2 and month(1)=1?

Code

function tock()
....
	printf("\n[%d] TOCK -- [%s] month()=%d  month(1)=%d... ",utcHHMM, Asset,month(),month(1));
	if(month()!=month(1) or Init) {		
		sprintf(OptionFile,"%s\\%s_%d%02d_m1.t8", HistFolder, Asset, year(),month());
		printf("T8: %s\n",OptionFile);
	}


..................Log entry................

[974: Fri 21-01-29 20:58] 3730.72/3734.22\3727.72/3727.72 -0.01
[2058] TOCK -- [SPX] month(0)=1 month(1)=1...

[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] TOCK -- [SPX] month(0)=2 month(1)=2...

Re: New Zorro version 2.40.2 [Re: jcl] #483845
08/03/21 09:12
08/03/21 09:12
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Afraid not, but I now see the reason of the problem.

Inside a tick or tock function, month(0) is the current time. month(1) is the end of the previous bar. Depending on when the function runs, both can be identical. So your comparison is not good, even if it may have worked sometimes. For correctly finding a month change, either compare month(0) != month(1) in the run function, or compare month(0) in the tock function with month(0) of the previous tock.

Re: New Zorro version 2.40.2 [Re: jcl] #483846
08/03/21 09:37
08/03/21 09:37
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
2.40.3 is now out. Changes: Multiple 047 error messages suppressed, and fixes for the other reported issues.

Re: New Zorro version 2.40.2 [Re: jcl] #483847
08/03/21 12:32
08/03/21 12:32
Joined: May 2018
Posts: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
hi jcl,

I hear what you're saying. But I still believe there is a problem in 2.40 when tock was moved to execute after tick, which makes sense conceptually.

Take a look at these log clippings and you'll see the problem.

In v2.35, tock is executed before run(), and tock() has the same time stamp and BarNum as the upcoming run() , which make sense.

In v2.40, tock is executed before run(), and tock() has the new BarNum, BUT..... old timestamp of the previous bar.

This probably causes month(1) to equal month(0). I also did do as you suggested and check for month change in run(). But because of this problem, I am only able to detect a month change in bar 2 of the new month.

FYI, this the formula I used for the timestamp printed in the log.

int utcHHMM = hour()*100+minute();

Code
..................... v 2.35 and before .........................

[1430] Bar[975] TOCK -- [SPX] 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1432] Bar[976] TOCK -- [SPX] 
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72

................... v2.40 ............................................

[974: Fri 21-01-29 20:58] 3730.72/3734.22\3727.72/3727.72 -0.01
[2058] Bar[974] run() -- price=3727.72

[2058] Bar[975] TOCK -- [SPX]   <------------------------ bad time stamp for Bar 975. it should be 1430
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1430] Bar[976] TOCK -- [SPX] <--------------------------- bar time stamp for Bar 976.  it should be 1432
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72



Last edited by SBGuy; 08/03/21 12:33.
Re: New Zorro version 2.40.2 [Re: jcl] #483850
08/04/21 07:09
08/04/21 07:09
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The tock timestamp is _not_ the end of the next bar. It is simply the current time. In 2.40 tock is run by the internal state machine in the backtest, so that tock timestamps are always synchronized to the ticks. In 2.35, tock timestamps were unsynchronized.

Whether to detect month changes in run or in tock depends on what for you're using it. If your script must react immediately on a new month, even in the middle of a bar, then you must check the change of month(0) inside tock or tick. That's easy with a static variable.

Re: New Zorro version 2.40.2 [Re: jcl] #483852
08/04/21 09:01
08/04/21 09:01
Joined: Feb 2021
Posts: 19
C
CpOo Offline
Newbie
CpOo  Offline
Newbie
C

Joined: Feb 2021
Posts: 19
Originally Posted by jcl
Ah, ok. We'll check that and when it happens here too, it will be fixed. Since you found a bug in a release candidate, you're entitled for a 3 months free Zorro S subscription or support period - please contact Support for claiming the reward.


Thanks!

Re: New Zorro version 2.40.2 [Re: jcl] #483855
08/04/21 15:26
08/04/21 15:26
Joined: May 2018
Posts: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
hi jcl,

My understanding in 2.40 is that execution order is now: tick, TOCK, TMF, run.... instead of TOCK, tick, TMF, run as in 2.35.

My observation from this log snippet below is that a contractUpdate() in Bar 976 tock, will load the options chain from time 1430, which is Bar 975. The TMF that executes before run will used the options chain from 1430. This problem may not be that big using 2 minutes bars, but will be a big problem longer bars.

So... in short, my original month detection problem has evolved to a potential tick/tock/run timing problem.

See the log below.

In v2.35 all the bars have the same time stamp, i.e. tick, tock, run associated with Bar 976 have a timestamp of 1432, which makes sense.
In v2.40 tick, tock in Bar 976 have a time of 1430, and run has a time of 1432... doesn't look right to me.

Thanks for looking closer at this.

Code

................... v2.35 ......................... TOCK, tick, TMF, run

[1430] Bar[975] TOCK -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[1430] Bar[975] tick -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1432] Bar[976] TOCK -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[1432] Bar[976] tick -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... 
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72

.................. v2.40 ......................... tick, TOCK, TMF, run

[2058] Bar[975] tick -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[2058] Bar[975] TOCK -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1430] Bar[976] tick -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... 
[1430] Bar[976] TOCK -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72



The test script

Code
#include <stdio.h>
#include <default.c>

#define TICKER			"SPX"

string HistFolder[200];
string OptionFile[200];

bool NewMonth;
int LastMonth, RunMonth;

void main()
{	
	sprintf(HistFolder,"C:\\Zorro\\History\\%s-Options\\",TICKER);		
}


function tick()	
{
	int utcHHMM = hour()*100+minute();
	printf("\n[%d] Bar[%d] tick -- [%s] LastMonth[%d] RunMonth[%d] NewMonth[%d]... ",utcHHMM, Bar, Asset,LastMonth, RunMonth, NewMonth);	
}

function tock()	
{
	int myHour = lhour(ET);
	int myMins = minute();
	int HHMM = myHour*100+myMins;
	
	int utcHHMM = hour()*100+minute();

	printf("\n[%d] Bar[%d] TOCK -- [%s] LastMonth[%d] RunMonth[%d] NewMonth[%d]... ",utcHHMM, Bar, Asset,LastMonth, RunMonth, NewMonth);
	if(month(0)!=LastMonth) {		
		sprintf(OptionFile,"%s\\%s_%d%02d_m1.t8", HistFolder, Asset, year(),month());
		printf("USE NEW T8: %s\n",OptionFile);
		//contractUpdate().....
	}
}


void run() 
{
	NewMonth = month(0)!=month(1);
	RunMonth = month(0);
	LastMonth = month(1);
	
	int utcHHMM = hour()*100+minute();

	Verbose = 3;	//7|DIAG;

	StartDate = 20210301;
	EndDate = 	20210303;	
		
	static char HistoryPath[100];
	strcpy(HistoryPath,strf("%s\\*_mm.t6",HistFolder));
	History = HistoryPath;		

	BarPeriod = 2;		
	LookBack = 115*30;	// 115 1-hour bar look back
	
	BarZone = ET;
	StartMarket = 0930;			//ET Time
	EndMarket = 1600;				//ET Time
	BarMode = BR_WEEKEND+BR_MARKET+BR_SLEEP;
	TickTime = 1*60*1000;
	TockTime = 1*60*1000;
	set(PRELOAD);
	set(LOGFILE);
	
	asset("SPX");
	printf("\n[%d] Bar[%d] run() -- price=%.2f\n", utcHHMM, Bar, priceClose());
	
}


Re: New Zorro version 2.40.2 [Re: jcl] #483858
08/05/21 13:51
08/05/21 13:51
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Hmm. If bar N ends with time t1, and bar N+1 ends with time t2, then I would normally expect for all the ticks and tocks of bar N+1 timestamps that start with t1 and end with t2. Won't you agree?

Re: New Zorro version 2.40.2 [Re: jcl] #483861
08/05/21 17:09
08/05/21 17:09
Joined: May 2018
Posts: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
I'm not sure I know enough about the internals of Zorro to opine on your question.

But let me ask you this in the context of my specific application, using the details of the log entries below:

If contractUpdate() is called in Bar 976 TOCK, or tick, which has a timestamp of 1430, which contract chain do you think will be loaded?
(a) the chain for time of 1430 (the tick/tock timestamp)
(b) the chain for time of 1432 (the Bar 976 time)

Code
.................. v2.40 ......................... tick, TOCK, TMF, run

[2058] Bar[975] tick -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[2058] Bar[975] TOCK -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1430] Bar[976] tick -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... 
[1430] Bar[976] TOCK -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72

Page 3 of 7 1 2 3 4 5 6 7

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