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 returns incorrect IBar.getTime
 Post subject: history.getBars returns incorrect IBar.getTime Post rating: 0   New post Posted: Tue 14 Feb, 2012, 22:34 

User rating: 0
Joined: Thu 23 Jun, 2011, 07:26
Posts: 18
Location: United KingdomUnited Kingdom
I have the following code:
List<IBar> barsAsk = history.getBars(instrument, Period.ONE_HOUR, OfferSide.ASK, (Filter)Filter.NO_FILTER, hour + 3, bidBar.getTime(), 0);
for (IBar bar : barsAsk) {
if (bar.getHigh() > high)
high = bar.getHigh();

timeprint(bar.getTime(), "Open:" + bar.getOpen() + ", Close:" + bar.getClose() + ", High:" + bar.getHigh() + ", Volume: " + bar.getVolume());
}

The problem is that bar.getTime() returns a fixed time for every bar retrieved. This only happens in Demo mode with the latest 2.6.57 JForex API.
It works perfectly during Test mode (Historical tester).
Here is a snippet of the history bars for the above code during demo mode:
1329210000067:Tue Feb 14 09:00:00 GMT 2012: Open:1.0703, Close:1.07214, Low:1.06985, Volume: 6804.01
1329210000067:Tue Feb 14 09:00:00 GMT 2012: Open:1.07214, Close:1.06917, Low:1.06915, Volume: 7227.56
1329210000067:Tue Feb 14 09:00:00 GMT 2012: Open:1.06917, Close:1.06843, Low:1.06749, Volume: 8537.78
1329210000067:Tue Feb 14 09:00:00 GMT 2012: Open:1.06841, Close:1.06777, Low:1.06666, Volume: 9179.95
1329210000067:Tue Feb 14 09:00:00 GMT 2012: Open:1.06777, Close:1.06791, Low:1.06742, Volume: 7639.59
1329210000068:Tue Feb 14 09:00:00 GMT 2012: Open:1.06788, Close:1.0687, Low:1.06777, Volume: 5327.35
1329210000068:Tue Feb 14 09:00:00 GMT 2012: Open:1.0687, Close:1.0683, Low:1.06631, Volume: 7223.06
1329210000068:Tue Feb 14 09:00:00 GMT 2012: Open:1.06827, Close:1.06849, Low:1.06671, Volume: 6918.12
1329210000068:Tue Feb 14 09:00:00 GMT 2012: Open:1.06848, Close:1.0689, Low:1.06766, Volume: 7301.76

And the same code run in Test mode (historical tester):
1325721600000:Thu Jan 05 00:00:00 GMT 2012: Open:1.29314, Close:1.29339, High:1.29415, Volume: 9360.94
1325725200000:Thu Jan 05 01:00:00 GMT 2012: Open:1.29339, Close:1.29233, High:1.29376, Volume: 9035.61
1325728800000:Thu Jan 05 02:00:00 GMT 2012: Open:1.29233, Close:1.29315, High:1.2935, Volume: 7410.45
1325732400000:Thu Jan 05 03:00:00 GMT 2012: Open:1.29315, Close:1.2929, High:1.29327, Volume: 7072.93
1325736000000:Thu Jan 05 04:00:00 GMT 2012: Open:1.2929, Close:1.29241, High:1.29333, Volume: 6144.07
1325739600000:Thu Jan 05 05:00:00 GMT 2012: Open:1.29241, Close:1.29169, High:1.29254, Volume: 8628.53
1325743200000:Thu Jan 05 06:00:00 GMT 2012: Open:1.29169, Close:1.29194, High:1.29224, Volume: 9755.57
1325746800000:Thu Jan 05 07:00:00 GMT 2012: Open:1.29196, Close:1.29348, High:1.29385, Volume: 14885.76
1325750400000:Thu Jan 05 08:00:00 GMT 2012: Open:1.29347, Close:1.28738, High:1.29443, Volume: 21166.84
1325714400000:Wed Jan 04 22:00:00 GMT 2012: Open:1.29423, Close:1.2936, Low:1.29328, Volume: 4007.47
1325718000000:Wed Jan 04 23:00:00 GMT 2012: Open:1.2937, Close:1.29304, Low:1.29287, Volume: 4861.21

You can clearly see the .getTime() method is returning the correct results for TEST mode but not for Demo mode.

Geoff.


 
 Post subject: Re: history.getBars returns incorrect IBar.getTime Post rating: 0   New post Posted: Wed 15 Feb, 2012, 09:30 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We did not manage to replicate the issue. Please have a look if the timeprint function is correct. Note that you could print out about the same information by using IBar.toString() method, i.e.:
console.getOut().println(bar);


 
 Post subject: Re: history.getBars returns incorrect IBar.getTime Post rating: 0   New post Posted: Wed 15 Feb, 2012, 09:44 

User rating: 0
Joined: Thu 23 Jun, 2011, 07:26
Posts: 18
Location: United KingdomUnited Kingdom
Yep. My bad! I had a switch in the function that used a system Calendar call in Demo mode. Late night... :roll:


 

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