Messy Bars construction

Posted By: byakuren81

Messy Bars construction - 10/02/17 10:07

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.
Posted By: Hredot

Re: Messy Bars construction - 10/02/17 12:20

As a rule of thumb, I guess this should not matter, since actually good trading strategies should be robust against such small fluctuations.
Posted By: byakuren81

Re: Messy Bars construction - 10/02/17 13:38

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.
Posted By: jcl

Re: Messy Bars construction - 10/02/17 15:02

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.
Posted By: byakuren81

Re: Messy Bars construction - 10/02/17 15:25

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...
Posted By: AndrewAMD

Re: Messy Bars construction - 10/02/17 15:58

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.
Posted By: byakuren81

Re: Messy Bars construction - 10/02/17 18:25

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...
Posted By: AndrewAMD

Re: Messy Bars construction - 10/02/17 19:17

Originally Posted By: byakuren81
By the way fyi one second is 1e6 microseconds and not 1e3, this is milliseconds...
Fixed, thanks.
Posted By: AndrewAMD

Re: Messy Bars construction - 10/02/17 20:12

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?
Posted By: byakuren81

Re: Messy Bars construction - 10/02/17 21:31

Leave it, everything is fine, sorry for the waist of time.
© 2024 lite-C Forums