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.

Start Time of Historical Daily Bars
 Post subject: Start Time of Historical Daily Bars Post rating: 0   New post Posted: Wed 01 Sep, 2021, 20:18 

User rating: 0
Joined: Wed 01 Sep, 2021, 19:12
Posts: 1
Location: United KingdomUnited Kingdom
Hello,

I would like my strategy to retrieve the 6 previous daily bars.
I've found the IHistory.getBars method and have used it as follows.

long prevBarTime = history.getPreviousBarStart(Period.DAILY, askBar.getTime());
List<IBar> askBars = history.getBars(Instrument.EURUSD, Period.DAILY, OfferSide.ASK, Filter.WEEKENDS, 6, prevBarTime, 0);


The problem I've run into is the start time of the daily bars, they have a start time of midnight.
Which threw me because when you download historical data to CSV files or view daily bars in JForex they start at 21:00 (or 22:00 for parts of the year).

What I'm trying to get to is 1 bar for Sunday through Monday and 1 bar Monday through Tuesday etc... rather than 24 hour periods.
Is this possible?


Regards


 
 Post subject: Re: Start Time of Historical Daily Bars Post rating: 0   New post Posted: Mon 27 Sep, 2021, 14:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6118
Greetings.

Try this:

Period dailyEET = Period.createCustomPeriod(Unit.Day, 1, JFTimeZone.EET);
long prevBarTime = history.getPreviousBarStart(dailyEET, history.getStartTimeOfCurrentBar(Instrument.EURUSD, dailyEET));
List<IBar> askBars = history.getBars(Instrument.EURUSD, dailyEET, OfferSide.ASK, Filter.WEEKENDS, 6, prevBarTime, 0);

Regard.


 

Jump to:  

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