Dukascopy
 
 
Wiki JStore Search Login

getBars wrong bars returned
 Post subject: getBars wrong bars returned Post rating: 0   New post Posted: Tue 24 Sep, 2013, 20:51 
User avatar

User rating: 0
Joined: Wed 03 Jul, 2013, 14:08
Posts: 16
Location: BrazilBrazil
Hi all,

Why this code return 4 bars?

       List<IBar> bars = history.getBars(Instrument.EURUSD,
                Period.ONE_HOUR,
                OfferSide.BID,
                Filter.WEEKENDS,
                2,
                history.getBarStart(Period.ONE_HOUR, 1202076000000 ),
                1);



[1201896000000[2008-02-01 20:00:00.000+0000] O: 1.4803 C: 1.4798 H: 1.4805 L: 1.47955 V: 168137.0, 
1201899600000[2008-02-01 21:00:00.000+0000] O: 1.4798 C: 1.48 H: 1.4802 L: 1.4794 V: 128028.0,
1202076000000[2008-02-03 22:00:00.000+0000] O: 1.4805 C: 1.4798 H: 1.4806 L: 1.4792 V: 5336.0,
1202079600000[2008-02-03 23:00:00.000+0000] O: 1.4798 C: 1.48025 H: 1.4804 L: 1.4791 V: 29227.0]


The correct IMHO will be three bars.

Bug?


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Wed 25 Sep, 2013, 09:28 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Javadoc says:
numberOfCandlesBefore - how much candles to load before and including candle with time specified in time parameter
numberOfCandlesAfter - how much candles to load after (not including) candle with time specified in time parameter

So that is 2(+1)+1.


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Wed 25 Sep, 2013, 09:42 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It should be 3 bars, the issue has been registered.


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Wed 25 Sep, 2013, 09:49 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Ehh, why? :shock:

Is the javadoc not correct as well? Or what is going on?


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Wed 25 Sep, 2013, 10:02 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
javadocs are correct - 2+1=3, and then the candle with the passed time is last one among the numberOfCandlesBefore.


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Fri 27 Sep, 2013, 09:30 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
But in the original post candlesAfter parameter was set to 1:
       List<IBar> bars = history.getBars(Instrument.EURUSD,
                Period.ONE_HOUR,
                OfferSide.BID,
                Filter.WEEKENDS,
                2, // <-candlesBefore
                history.getBarStart(Period.ONE_HOUR, 1202076000000 ),
                1); // <-candlesAfter


So my assumption was:
candlesBefore: 2. This gives the last 2 candles before the given time, +1 candle of the given time, as it is included.
candlesAfter: 1. This gives the first candle after the given time.
So in total this is 2+1+1.
Do I misunderstand something?


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Fri 27 Sep, 2013, 12:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
tcsabina wrote:
candlesBefore: 2. This gives the last 2 candles before the given time, +1 candle of the given time, as it is included.
There is no +1, since candlesBefore includes the candle of the time parameter, this is quite clearly stated in the javadocs.


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Sun 29 Sep, 2013, 04:34 
User avatar

User rating: 0
Joined: Wed 03 Jul, 2013, 14:08
Posts: 16
Location: BrazilBrazil
I'm getting wrong (missing) values too;

For time 1359763200000 I got:

history.getBarStart(Period.DAILY, 1359763200000 ) == 1359763200000 


Where is my time: 1359763200000 on the result?

[1359590400000[2013-01-31 00:00:00.000+0000] O: 1.3568 C: 1.36115 H: 1.36165 L: 1.35408 V: 166226.06, 
1359676800000[2013-02-01 00:00:00.000+0000] O: 1.36115 C: 1.36391 H: 1.37108 L: 1.35857 V: 204480.61,
1359849600000[2013-02-03 00:00:00.000+0000] O: 1.36391 C: 1.36391 H: 1.36391 L: 1.36391 V: 0.0]


Same times return wrong number of values, other times return correct number of values, but wrong values.


 
 Post subject: Re: getBars wrong bars returned Post rating: 0   New post Posted: Tue 01 Oct, 2013, 12:10 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
API Support wrote:
There is no +1, since candlesBefore includes the candle of the time parameter...

Oh, I see now!


 

Jump to:  

  © 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