Gamestudio Links
Zorro Links
Newest Posts
Optimize issues
by jbhunter. 03/28/20 05:36
Z12 and Oanda: !trade not open
by jj02520024. 03/28/20 00:38
Market closed on friday at 17 UTC?
by AndrewAMD. 03/27/20 23:30
I AM SO LOST
by sdh309795gaas. 03/27/20 14:44
M1 tick data format
by jbhunter. 03/27/20 12:47
Random Functions?
by txesmi. 03/27/20 12:28
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
4 registered members (kvm, 7th_zorro, 3run, jbhunter), 614 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
heitorfr, Art__, bmmtrader, buttcorgi, MassimoPicco
18405 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Keeping non-24h markets synchronized in live and backtest #462773
10/27/16 15:03
10/27/16 15:03
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
Hi all,

when I trade a non-24h market, like the FXCM NAS100, I get different live results than in the backtest. That's because Zorro generates bars from the closed market and then the system with its indicators is executed differently than within a backtest (see figures, the red circle shows the surplus bars generated by live Zorro).

I tried to fix this issue with hour() and StartMarket/EndMarket but I get a series error.

How can Zorro be told to just execute the system when the market is open?

/Matt

Attached Files
NAS Live.PNG (17 downloads)
NAS Back.PNG (11 downloads)
Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #462778
10/28/16 07:05
10/28/16 07:05
Joined: Aug 2016
Posts: 48
D
dr_panther Offline
Newbie
dr_panther  Offline
Newbie
D

Joined: Aug 2016
Posts: 48
You could define the open time of a market like that
(from the manual)

Code:
function run()
{
  ...
  StartWeek = 10400; // start Monday 4 am
  EndWeek = 51900; // end Friday 7 pm
  Weekend = 7; // log off during the weekend
  ...
}


Re: Keeping non-24h markets synchronized in live and backtest [Re: dr_panther] #462816
10/30/16 08:34
10/30/16 08:34
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
Hey, thanks! StartWeek/EndWeek work, but they skip bars only at the beginning and end of the week.I am looking for a function that skips bars once a day.

In the meanwhile I found the TimeFrame function. The manual states that it is for "for skipping bars outside market hours or when no price ticks arrive". I implemented this code to my script.

Code:
// skipping bars for a certain time period 
	static int BarsMissing = 0;
	if(hour() >= 21 and hour() < 22) // 0 when the current bar has no price quotes   
	{ 
  		TimeFrame = 0; // set to zero when not in frame
  		BarsMissing++;
	}
	else if (hour() == 22 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


But only the prices and indicator values are fixed for the specified time period and no bars are skipped. Anything wrong with the implementation?

Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #462836
10/31/16 11:17
10/31/16 11:17
Joined: Jul 2000
Posts: 27,148
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,148
Frankfurt
I am not sure what you mean with "skipping" bars, but if you want to restrict your trading to market hours, use the hour() or lhour() function for this. You can normally get the market hours for your asset from the broker's website.

Bars are skipped when the asset is not traded and there are no price quotes. This depends on the asset, not on your script.

Re: Keeping non-24h markets synchronized in live and backtest [Re: jcl] #462853
11/01/16 09:42
11/01/16 09:42
Joined: Aug 2016
Posts: 48
D
dr_panther Offline
Newbie
dr_panther  Offline
Newbie
D

Joined: Aug 2016
Posts: 48
I think he wants to just consider particular bar for the calculation of an indicator.

MattY included 2 images, and the indicator is also calculated for some "flat" bars, this bars should be excluded in the calculation of an indicator.

For example lets say I just want to have the EMA from 8:00 - 16:00 UTC, that means every bar between 4pm and 8am is ignored in the calculation, is this possible?

Re: Keeping non-24h markets synchronized in live and backtest [Re: dr_panther] #462884
11/02/16 20:33
11/02/16 20:33
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
Hi dr_panther, jcl,

that is exactly what I mean. I want to skip the bars when the market is closed. For the FXCM NAS100 this is between 20:15 - 20:30 and 21:00 - 22:00 UTC. See image "NAS100 Historical". These times are not in the data history and I also do not receive any live quotes during these times in the FXCM Trading station. But Zorro seems to run its quoting and logging and produces these bars with always the same price. See image "NAS100 Zorro" for an example.

Therefore the Zorro live data is different from the historical data and the indicators are calculated differently. And the whole system behaves differently as in the backtest/simulation. For me this is a big problem.

jcl, is there no way to exclude these times? If not, please consider to implement it in a future version.

Attached Files
NAS100 Historical.PNG (5 downloads)
NAS100 Zorro.PNG (98 downloads)
Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #462973
11/08/16 22:29
11/08/16 22:29
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
If you want to trade during certain hours try this:

if(between(hour(),15,21)..............)

This will trade from 15:00 to 21:00 UTC

Re: Keeping non-24h markets synchronized in live and backtest [Re: Finstratech] #462986
11/09/16 20:36
11/09/16 20:36
Joined: Jun 2016
Posts: 9
Germany, BW
MattY Offline OP
Newbie
MattY  Offline OP
Newbie

Joined: Jun 2016
Posts: 9
Germany, BW
Thanks, but if I add an hour() condition to the complete function run() I get this error:

Quote:
Error 041: Inconsistent series calls / too many series
Number or order of series calls in the script are different between run cycles, due to a bug in the script. Make sure that all series calls - or function calls that internally create series, such as LowPass, ATR, etc. - have the same order in every run, and are not skipped with if statements. Make also sure that your script does not generate series in tick-based intrabar functions (TMF, tick) or in endless loops.


And I think it's not enough to put the entry and exit statements in an hour() condition, because I also don't want the indicators to be calculated for a specific time.

/Matt

Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #463066
11/12/16 22:29
11/12/16 22:29
Joined: Aug 2016
Posts: 48
D
dr_panther Offline
Newbie
dr_panther  Offline
Newbie
D

Joined: Aug 2016
Posts: 48
I waited for a better solution before making this suggestion:

Would it be possible to remove the unwanted bars from the history file and restart zorro, this should calculate the indicators from the remaining bars and if the deleted bars are not the last ones, it would not reload it from the data provider.

I know its very dirty, but I don't know an elegant way to achieve it, to be honest I even don't know if my suggestion would work.

Re: Keeping non-24h markets synchronized in live and backtest [Re: MattY] #463069
11/13/16 00:43
11/13/16 00:43
Joined: Apr 2014
Posts: 481
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 481
Sydney, Australia
@MattY - you would get that error if you put a series definition inside the if() statement. Series need to be created in the same way and in the same order for each iteration of the run function, therefore you shouldn't put them inside flow control statements.

You could try defining your series outside the if() statement, and then wrapping only your entry logic inside the if() statement. Example:

Code:
vars mySeries = series(...);

if(tradeCondition == true)
{
   Entry = priceHigh();
   enterLong();
}


Page 1 of 2 1 2

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