Dukascopy Support Board

Start Time of Historical Daily Bars
Page 1 of 1

Author:  NobleMarlin9048 [ Wed 01 Sep, 2021, 20:18 ]
Post subject:  Start Time of Historical Daily Bars


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?


Author:  API Support [ Mon 27 Sep, 2021, 14:10 ]
Post subject:  Re: Start Time of Historical Daily Bars


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);


  Page 1 of 1