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: 1   New post Posted: Mon 27 Sep, 2021, 14:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
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.


 
 Post subject: Re: Start Time of Historical Daily Bars Post rating: 0   New post Posted: Mon 22 Nov, 2021, 17:02 
User avatar

User rating: 0
Joined: Sun 12 May, 2019, 02:54
Posts: 1
Location: Belarus, Minsk
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 155 times
StrategyLog _ERROR.png [49.98 KiB]
Downloaded 273 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

Jump to:  

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