Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

getBarStart algorithm
 Post subject: getBarStart algorithm Post rating: 0   New post Posted: Fri 29 Apr, 2011, 14:31 

User rating: -
Is it safe to assume the following?
IHistory.getBarStart(FIVE_MINS,tick.getTime()) == (tick.getTime()%(1000*60*5))

(I would like to use this assumption to avoid a certain dependency on IHistory if possible. However, I don't know whether issues such as leap seconds may cause the assumption to be violated.)

Isak


 
 Post subject: Re: getBarStart algorithm Post rating: 0   New post Posted: Thu 09 Jun, 2011, 11:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes, because bars consist of ticks (i.e. all bar values like prices and volume are aggregated from ticks within the time frame of the bar).


 
 Post subject: Re: getBarStart algorithm Post rating: 0   New post Posted: Thu 09 Jun, 2011, 14:02 
User avatar

User rating: 6
Joined: Thu 19 May, 2011, 11:14
Posts: 235
Location: South Africa,
CORRECTION:
IHistory.getBarStart(FIVE_MINS,tick.getTime()) == tick.getTime()-(tick.getTime()%(1000*60*5))

Thanks. The question was meant to focus on the modular arithmetic: whether leap seconds perturb the alignment of the bar boundaries.

It is more of a "Java time" question than a JForex question, but for the benefit of anyone who may have the same question, here is what I learned:

"in practice, Java represents time/date values as something that’s rather like a mutant version of TAI with seconds that are occasionally 2 seconds long to make it sync back up with UTC–although it claims to be reporting UTC. "

This means that round numbers remain aligned to the bar boundaries, and that it is safe to use simple modular arithmetic to compute bar boundaries.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com