Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Start Time of Historical Daily Bars
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=57708
Page 1 of 1

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

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

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

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.

Author:  we_told [ Mon 22 Nov, 2021, 17:02 ]
Post subject:  Re: Start Time of Historical Daily Bars

Dear Support Team,

This is a problem with the customized period Period.createCustomPeriod(Unit.Day, 1, JFTimeZone.EET). It appears that the customized period does not work with the function history.getBar() in the REMOTE mode.

The part is my code is below:
     framePeriod=Period.createCustomPeriod(Unit.Day, 1, JFTimeZone.EET);
     //framePeriod=Period.DAILY;
     dailyBar=history.getBar(Instrument.EURUSD,framePeriod, OfferSide.BID, 3);         
     console.getOut().println("Daily Bar test: High="+ dailyBar.getHigh()+", Low="+dailyBar.getLow()+", time="+sdf.format(dailyBar.getTime()));


This code is working for both DEMO and LIVE only in LOCAL mode, but not in REMOTE!!! The code crashed with NullPointerException at history.getBar(...).

Strategy Log:
Image

The full code is attached.

Attachments:
RemoteModeTest.java [2.96 KiB]
Downloaded 157 times
StrategyLog _ERROR.png [49.98 KiB]
Downloaded 276 times

  Page 1 of 1