Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Quad, EternallyCurious, 1 invisible), 737 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Keeping non-24h markets synchronized in live and backtest [Re: boatman] #463088
11/14/16 20:44
11/14/16 20:44
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
@dr_panther: the history doesn't have unwanted bars. It's the live data that have these additional wrong bars. That's because Zorro's quoting is running when the particular market is closed. And then it produces additional bars that are not in the history.

@boatman: when I put only the entry logic inside the if() statement I get no error that's right. But I can't skip these additional live bars. So, I tried to put the whole run() function inside an if statement to execute the system only during these times.

I am stuck, here. A function like StartWeek/EndWeek would be needed so that Zorro logs out at the end of the day and doesn't produce these surplus bars, something like StartDay/EndDay.

Doesn't anybody else have these live trading problem? It should occur with every non-24h market and on a lot of timeframes.

BTW: I tried it also with IB in demo-mode. It's the same behaviour.

Last edited by MattY; 11/14/16 20:45.
Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #463092
11/14/16 22:39
11/14/16 22:39
Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
F
Finstratech Offline
Junior Member
Finstratech  Offline
Junior Member
F

Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
Play with this:

Code:
// create a midnight-aligned daily price series
static int BarsPerDay = 0;
if(hour(0) < hour(1)) { // day change  
  TimeFrame = -BarsPerDay; // end the frame
  BarsPerDay = 0;
} else {
  TimeFrame = 0; // inside the frame
  BarsPerDay++;  // count number of bars per day
}
vars PriceD1 = series(price());

// alternative: a midnight-aligned price series using frameSync()
StartWeek = 10000;
TimeFrame = frameSync(H24);
vars PriceD1 = series(price());



Also enter "time zone" in the search bar of the HTML Help document located in the main Zorro folder.

Re: Keeping non-24h markets synchronized in live and backtest [Re: Finstratech] #463117
11/15/16 23:56
11/15/16 23:56
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Finstratech is right - you need to set up the TimeFrame correctly. I typically use AssetZone, and then set TimeFrame to AssetFrame. Then use FrameOffset to sample prices at the time of interest.

Re: Keeping non-24h markets synchronized in live and backtest [Re: boatman] #463153
11/18/16 10:41
11/18/16 10:41
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
Hey, I figured it out finally. Actually the code here does the job.

Code:
// skipping bars for a certain time period 
	static int BarsMissing = 0;
	if(hour() >= 19 and hour() < 20) // 0 when the current bar has no price quotes   
	{ 
  		TimeFrame = 0; // set to zero when not in frame
  		BarsMissing++;
	}
	else if (hour() == 20 and minute() == 0 )
	{ 
  		TimeFrame = -BarsMissing; //  set TimeFrame to the negative number of skipped bars for ending the frame
  		BarsMissing = 0;
	}
	else
		TimeFrame = 1;	// Normal operation



So, I had it but I didn't see it. Thanks for pushing me in the right direction, again. The reason is I thought Zorro would produce no log file, when skipping bars. But it does and freezes all indicator and other values when TimeFrame is 0. See here:

Quote:
[2408: Thu 17.11.16 18:55] +0 +205 64/3 4825/4826\4824/4824 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 1

[2409: Thu 17.11.16 19:00] +0 +187 64/3 4824/4825\4820/4821 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2410: Thu 17.11.16 19:05] +0 +167 64/3 4820/4821\4816/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2411: Thu 17.11.16 19:10] +0 +167 64/3 4815/4818\4813/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2412: Thu 17.11.16 19:15] +0 +170 64/3 4817/4819\4816/4818 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2413: Thu 17.11.16 19:20] +0 +187 64/3 4818/4821\4818/4821 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2414: Thu 17.11.16 19:25] +0 +167 64/3 4819/4821\4817/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2415: Thu 17.11.16 19:30] +0 +150 64/3 4818/4818\4814/4815 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2416: Thu 17.11.16 19:35] +0 +141 64/3 4814/4815\4811/4813 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2417: Thu 17.11.16 19:40] +0 +160 64/3 4813/4817\4813/4816 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2418: Thu 17.11.16 19:45] +0 +153 64/3 4817/4819\4815/4815 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2419: Thu 17.11.16 19:50] +0 +157 64/3 4815/4818\4814/4816 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2420: Thu 17.11.16 19:55] +0 +149 64/3 4816/4817\4814/4814 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0

[2421: Thu 17.11.16 20:00] +0 +166 64/3 4816/4818\4814/4817 Close: 4817.25, Ind: 4823.35, AssetFrame: 1, TimeFrame: -12

[2422: Thu 17.11.16 20:05] +0 +178 64/3 4818/4820\4817/4819 Close: 4819.40, Ind: 4822.36, AssetFrame: 1, TimeFrame: 1

Page 2 of 2 1 2

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