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.

How to get Weekly bar to open on Sunday, not Monday
 Post subject: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Wed 13 Apr, 2011, 15:07 

User rating: 1
Joined: Sun 05 Dec, 2010, 08:44
Posts: 21
I've just found that bars in the Weekly time frame open on Mondays 00:00:00. This can be found by checking the return value of:

history.getBar(Instrument.EURUSD, Period.WEEKLY, OfferSide.BID, 0).getTime()


This is strange because, based on your historical data, the markets open at Sunday 21:00:00 and close on Friday 21:00:00. So we miss out on the first 3 hours of data each week if we use the Weekly time frame in the onBar method.

So how can we make weekly bars open at the real start of the week and not on Monday 00:00:00?


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Thu 14 Apr, 2011, 09:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
You can't, weekly bars are generated by the calendar weeks starting on Monday. Sunday hours are included in the previous bar.


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Thu 14 Apr, 2011, 10:33 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Dear Support team,

I would strongly agree with Hyperdimension, the market opening on Sunday evening does belong to the new trading week.
Dukascopy also does offer to merge daily Sunday into Monday bars and not to merge Sunday into Friday bars.

Why don't you just switch the start of the week to Sunday? This should keep changes in your code minimal.
Calendar c = Calendar.getInstance();   c.setFirstDayOfWeek(Calendar.SUNDAY);


Let's please submit this change as a feature request.
Depending on the strategy, this might have an effect on trading signals in strategies.
I would therefore give this a high priority to change!
Do you accept this post as an official feature request or would you like us to open a new feature request in the respective subforum?

Best, RR.

PS: Subsequently, this applies to all other higher timeframes as well, such as MONTHLY and YEARLY. If the last day in a period is SUNDAY, the Sunday evening data should get merged with the following Monday data. This might cause a bit more coding on your side. I would rate the priority for WEEKLY higher than for MONTHLY and YEARLY, but nevertheless to get a clean datapool IMHO the change should get considered.


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Sat 16 Apr, 2011, 18:19 

User rating: 1
Joined: Sun 05 Dec, 2010, 08:44
Posts: 21
RoadRunner wrote:
Dear Support team,
PS: Subsequently, this applies to all other higher timeframes as well, such as MONTHLY and YEARLY.


Monthly bars should only open on the first day of each month regardless of the day of week.
Yearly bars should only open on the first day of each year regardless of the day of week.

However, Weekly bars should always open on Sunday, regardless of day of month.

This is the way it is in other trading platforms.


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Mon 18 Apr, 2011, 00:11 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hi Hyperdimension,

if the first day of a month is a Monday, you still want to have the Sunday evening data kept in the old month?
Are your sure?
If all Sunday evenings are merged into the Monday bars, this should also apply to Mondays that are the first of a month or year.
Just my 2 cents on it.

Best, RR.


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Tue 19 Apr, 2011, 15:58 

User rating: 1
Joined: Sun 05 Dec, 2010, 08:44
Posts: 21
RoadRunner wrote:
if the first day of a month is a Monday, you still want to have the Sunday evening data kept in the old month?

Yes, monthly bars should only ever start on YYYY-MM-01 00:00:00.000. The price of the tick just before YYYY-MM-01 00:00:00.000 would be the close price of the previous monthly bar, regardless of day of week (which could be almost any day of the week). Day of week should never be involved in the creation of monthly bars.


 
 Post subject: Re: How to get Weekly bar to open on Sunday, not Monday Post rating: 0   New post Posted: Thu 21 Apr, 2011, 15:07 

User rating: 1
Joined: Sun 05 Dec, 2010, 08:44
Posts: 21
I have made a feature request here: Weekly bars should open on Sunday


 

Jump to:  

cron
  © 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