Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Share CFD Trading Hours #464098
01/22/17 11:35
01/22/17 11:35
Joined: Aug 2016
Posts: 95
Wien
T
trenki2 Offline OP
Junior Member
trenki2  Offline OP
Junior Member
T

Joined: Aug 2016
Posts: 95
Wien
I want to trade Share CFDs with my Zorro S on FXCM and I see, that depending on the asset to be traded there are different trading hours:

Trading Hours

Currently in the backtest I simply use the Yahoo Finance history downloaded with the assetHistory() call and a BarPeriod of 1440.

Will Zorro take care of the different trading hours automatically and only trade when possible or do I have to manually add code to make Zorro trade only in the hours when the underlying exchange is open? Do I have to use AssetZone, AssetFrame, TimeFrame, FrameOffset and frameSync?

If extra code is required, do I manually have to skip bars outside trading hours? How would that work with TimeFrame, I don't fully understand the example in the documentation. How would I trade daily bars 1 hour before the close of the exchange?


Last edited by trenki2; 01/22/17 11:50.
Re: Share CFD Trading Hours [Re: trenki2] #464126
01/24/17 09:14
01/24/17 09:14
Joined: Aug 2016
Posts: 95
Wien
T
trenki2 Offline OP
Junior Member
trenki2  Offline OP
Junior Member
T

Joined: Aug 2016
Posts: 95
Wien
It looks like when I want to trade I need to manually make sure to only trade in the market hours as a test run did not work. It wanted to trade at midnight.

Now the issue is, that I only have daily data from Yahoo with a BarPeriod of 1440. So using a smaller BarPeriod when training and testing does not work.

I imagined I might be able to do something like the following code, but only when trading and still train only on the daily Yahoo data:

Code:
while (asset(loop(...)))
{	
	if (is(TRADEMODE))
	{
		FrameOffset = 15;
		AssetZone = ET;
	
		if (lhour(AssetZone) == FrameOffset) {
			TimeFrame = -AssetVar[0];
			AssetVar[0] = 0;
		} else {
			TimeFrame = 0;
			AssetVar[0]++;
		}
	}
	
	Trade();
}



This should make sure that trades always get executed at 15:00 local time when the market is open.

Now I am not sure if this approach will work, when I train with BarPeriod 1440 and then set BarPeriod to 60 together with the above approach.

Does anyone have experience with this and some advice? Can I do like that or do I really need hourly data for this to work?

Re: Share CFD Trading Hours [Re: trenki2] #464193
01/27/17 14:25
01/27/17 14:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Here's an example of trading assets in different time zones:

http://manual.zorro-project.com/assetzone.htm

Using different bar periods for training and for trading could theoretically also work. But since I don't think someone did that before, you'll be a pioneer. Maybe there are side effects. Just try it.

Re: Share CFD Trading Hours [Re: jcl] #464247
01/30/17 17:25
01/30/17 17:25
Joined: Aug 2016
Posts: 95
Wien
T
trenki2 Offline OP
Junior Member
trenki2  Offline OP
Junior Member
T

Joined: Aug 2016
Posts: 95
Wien
I have adapted my script to use the above lines and also set up BarPeriod and LookBack differently in trade mode:

Code:
BarPeriod = ifelse(is(TRADEMODE), 60, 60 * 24);
LookBack = ifelse(is(TRADEMODE), 45 * 24, 45);



I'm having some issues with Error 055 and especially 047:

Code:
Warning 055: SGO.PA first 434 bars missing
Loading LYB prices.. 32910 min, 2366 bars added
Loading MNST prices.. 32895 min, 2367 bars added
Loading VZ prices.. 32910 min, 2366 bars added
Loading AAPL prices... 32895 min, 2367 bars added
Loading BIDU prices.. 32910 min, 2366 bars added
Loading USB prices.. 32595 min, 2387 bars added
Loading FDX prices.. 32925 min, 2365 bars added
Loading DLTR prices... 32880 min, 2368 bars added
Loading MCD prices.. 32955 min, 2363 bars added
Error 047: not enough bars (87 missing)
Logout.. ok



I already tried the PRELOAD flag but that does not help I only have daily data from yahoo.
Now in trade mode the Lookback should be 45 * 24 = 1080. In the log it says ~2360 bars added. Yet it says 32955 min while 45 * 24 * 60 = 64800.

So im a bit confused now by the numbers.

In my LookBack calculation I assumed that 1 day had 24 bars and simply multiplied 45 day lookback times 24.
Now I want to trade CFDs that don't trade 24hrs/day.
Should I then set TimeFrame to -8 instead of -24 when the frame ends and use 45 * 8 as LookBack?

What can i do to make this work?

Re: Share CFD Trading Hours [Re: trenki2] #464248
01/30/17 17:41
01/30/17 17:41
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Find out the number of bars per day, and set up the MinutesPerDay variable accordingly. It needs not be precise, but it must also not be totally off. You need the latest beta version. Make also sure that enough historical data is available from your broker. PRELOAD can not be used when you have no preloaded 1-hour data.

Re: Share CFD Trading Hours [Re: jcl] #464250
01/30/17 18:25
01/30/17 18:25
Joined: Aug 2016
Posts: 95
Wien
T
trenki2 Offline OP
Junior Member
trenki2  Offline OP
Junior Member
T

Joined: Aug 2016
Posts: 95
Wien
The actual problem was that Zorro tried to open the trades as 00:00 which was outside the market hours for the asset while FXCM still seems to be providing price data outside market hours for CFDs.

Is there a simpler way to make Zorro only open trades during market hours while still just using the Yahoo Daily historical data with a BarPeriod of 1440?

Maybe BarOffset and BarZone is what I need? Unfortunately it seems they can only be set up for the whole script and not per asset. I would like to trade assets where the BarZone and BarOffset are different per asset. Is there a way to make that work? (I get Error 030: Check lookback, settings, asset order)

There are also the promissing variables StartMarket and EndMarket which are supposed to have some default values but still they are not beeing used for deciding when to open a trade.


Last edited by trenki2; 01/30/17 18:41.

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