Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
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
2 registered members (7th_zorro, 1 invisible), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Messy Bars construction #468359
10/02/17 10:07
10/02/17 10:07
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Hello, I have noticed that sometimes there is no clear rule on how minute Bars are selected to form a Bar of a higher time frame. For example on EURUSD when selecting BarPeriod=240, sometimes the 4H Bar will take into account for instance the minute Bars from 00:01 to 4:00, sometimes the ones from 00:00 to 3:59, sometimes from 00:01 to 3:59, there does not seems to be any clear rule on how the higher time frame Bars are constructed, could you please explain me why and tell me if such a behaviour is normal?
Thanks in advance.

Re: Messy Bars construction [Re: byakuren81] #468367
10/02/17 12:20
10/02/17 12:20
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
As a rule of thumb, I guess this should not matter, since actually good trading strategies should be robust against such small fluctuations.

Re: Messy Bars construction [Re: Hredot] #468371
10/02/17 13:38
10/02/17 13:38
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Well that is your guess, my guess is that if such errors and approximations appear at that level there might be some with greater consequences elsewhere...If you trust a software tolerating such approximations, good luck to you.

Re: Messy Bars construction [Re: byakuren81] #468374
10/02/17 15:02
10/02/17 15:02
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Of course there are no "approximations" in time periods. The time precision is 2 microseconds. This has nothing to do with the number of bars in historical data, which depends on market time and price source, and is certainly not always 240 per 4 hours.

Re: Messy Bars construction [Re: jcl] #468376
10/02/17 15:25
10/02/17 15:25
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
That does not explain me how such a basic higher time frame Bar construction fails in always selecting the same 1M Bar dates. It is not clear to me if you consider that a 4H Bar at time 10:00 contains the 10:00 minute Bar that actually ends for most of providers at 10:00:59 or that the last one it should contain is the 1M Bar at 9:59. This has some importance especially when trading on financial figures...

Re: Messy Bars construction [Re: byakuren81] #468378
10/02/17 15:58
10/02/17 15:58
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: byakuren81
For example on EURUSD when selecting BarPeriod=240, sometimes the 4H Bar will take into account for instance the minute Bars from 00:01 to 4:00, sometimes the ones from 00:00 to 3:59, sometimes from 00:01 to 3:59,
Do you have a repeatable means to demonstrate this behavior?

By the way, this is how historical data is normally stored:
Code:
typedef struct T6
{
	DATE	time;	
	float fHigh, fLow;	
	float fOpen, fClose;	
	float fVal, fVol; // optional data, like spread and volume
} T6; // 6-stream tick, .t6 file content

The DATE format is a double value, where a full day is equal to 1.0. How an actual date is converted into a double value depends on both your broker plugin and what the broker itself provides the plugin.
Originally Posted By: jcl
The precision is about 2 microseconds.
1 day = 1.0.
2 microseconds = 2 / (24 hr * 60 min * 60 sec * 1,000,000 micro) = 2.31e-11

Bars have nothing to do with it.

Last edited by AndrewAMD; 10/02/17 19:08. Reason: micro not milli
Re: Messy Bars construction [Re: AndrewAMD] #468386
10/02/17 18:25
10/02/17 18:25
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Thx for your answer, I know how Zorro stores the data, and I wrote a while ago a C++ API for downloading historical quotes from Oanda, so I know how Oanda is storing the date of each 1M Bar, it is a string under the format yyyy-mm-ddTHH:MM:SS.000000Z, as I could not find any 1M Bar on EURUSD from Oanda having a number of seconds different from zero but also down to the number of microseconds, I am having some doubts on how Zorro is making the conversion from string to double. All the downloaded 1M Bars from Oanda should show 0s and 0 microseconds in their date and so when asking for 4H Bars they should be perfectly aligned and not as such.
By the way fyi one second is 1e6 microseconds and not 1e3, this is milliseconds...

Re: Messy Bars construction [Re: byakuren81] #468387
10/02/17 19:17
10/02/17 19:17
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: byakuren81
By the way fyi one second is 1e6 microseconds and not 1e3, this is milliseconds...
Fixed, thanks.

Re: Messy Bars construction [Re: byakuren81] #468389
10/02/17 20:12
10/02/17 20:12
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
So what exactly are the DATE values that are incorrectly meshing into the bars? Are the DATE values off by, say, a leap second or microsecond, leading to a DATE value of X.9999999, etc?

Re: Messy Bars construction [Re: AndrewAMD] #468394
10/02/17 21:31
10/02/17 21:31
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Leave it, everything is fine, sorry for the waist of time.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1