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.

history.getBars fails if called in onTick Method
 Post subject: history.getBars fails if called in onTick Method Post rating: 0   New post Posted: Tue 28 Feb, 2012, 14:09 

User rating: 1
Joined: Thu 23 Feb, 2012, 16:38
Posts: 44
The following getBars call fails with exception:
Exception thrown whiler running onTick method: Number of bars to load = 0 or time is not correct time for the period specified

This exception is caused by the following code:
history.getBars(instrument, period, OfferSide.BID, Filter.WEEKENDS, 2, time, 0);

The exception is thrown whenever the time-parameter is not equal to the exact start time of a bar in the given period. If you "normalize" the time before calling getBars with:
time = history.getBarStart(period, time);

the exception does not occur.
See the example strategie to reproduce the problem.


Attachments:
ExampleStrategy.java [2 KiB]
Downloaded 291 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.
 
 Post subject: Re: history.getBars fails if called in onTick Method Post rating: 0   New post Posted: Wed 29 Feb, 2012, 16:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
see:
IHistory.getBars javadocs


 

Jump to:  

  © 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