Dukascopy
 
 
Wiki JStore Search Login

ArrayIndexOutOfBoundsException when the day is a Friday or Saturday
 Post subject: ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Thu 13 Sep, 2012, 17:44 

User rating: 0
Joined: Sun 22 May, 2011, 23:43
Posts: 12
Location: Italy, Roma
I'm running the demo (Dukascopy Bank ver. 2.18.12 and JForex API ver. 2.7.2.1) and I get a similar problem. Some bug may still be there :-(

Here is an example code:

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (instrument.equals(Instrument.EURUSD) && period.equals(Period.FOUR_HOURS)) {
            long cur_time = my_context.getHistory().getBarStart(Period.DAILY, askBar.getTime());
            double lastSMA10 = my_context.getIndicators().sma(instrument, Period.DAILY, OfferSide.BID, AppliedPrice.CLOSE, 10, Filter.WEEKENDS, cur_time, cur_time)[0];
            context.getConsole().getOut().println("Last SMA 10 = "+lastSMA10);
        }
    }


I get an ArrayIndexOutOfBoundsException when the day is a Friday or Saturday and the hour of the askBar is 00 or 04 or 08 or 12 or 16 (but not when it is 20).
I would have expected this sort of exception only when the day is a Saturday or Sunday (since I'm using Filter.WEEKENDS), but surely not on a Friday.
Anyone can explain/fix this exception?

Thanks,
Paolo


 
 Post subject: Re: APICLIENT-312 ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Fri 14 Sep, 2012, 15:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please, provide exception in a stack trace.


 
 Post subject: Re: APICLIENT-312 ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Mon 17 Sep, 2012, 12:19 

User rating: 0
Joined: Sun 22 May, 2011, 23:43
Posts: 12
Location: Italy, Roma
Thanks for your reply.
I simply get this message:

11:12:59 Strategy tester: java.lang.ArrayIndexOutOfBoundsException: 0 @ example.IStrategy_sma_tester_abstract.onBar(IStrategy_sma_tester_abstract.java:66)

The line of code 66 refers to:

Quote:
double lastSMA10 = my_context.getIndicators().sma(instrument, Period.DAILY, OfferSide.BID, AppliedPrice.CLOSE, 10, Filter.WEEKENDS, cur_time, cur_time)[0];


As I said this happens when cur_time is Friday and Saturday with hour equal to 00, 04, 08, 12, and 16.

Kind regards,
Paolo


 
 Post subject: Re: APICLIENT-312 ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Tue 25 Sep, 2012, 07:37 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
2.7.3


 
 Post subject: Re: ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Tue 15 Jan, 2013, 11:38 

User rating: 0
Joined: Sun 22 May, 2011, 23:43
Posts: 12
Location: Italy, Roma
Right now I'm using JForex API version 2.7.5 and I get exactly the same issue reported at the beginning of this thread. I've never seen the bug fixed in any version so far. It is NOT a "Fixed Bug". Please investigate further this issue, thanks.


 
 Post subject: Re: ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Tue 15 Jan, 2013, 13:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The latest API version is 2.7.7


 
 Post subject: Re: ArrayIndexOutOfBoundsException when the day is a Friday or Saturday Post rating: 0   New post Posted: Wed 16 Jan, 2013, 18:28 

User rating: 0
Joined: Sun 22 May, 2011, 23:43
Posts: 12
Location: Italy, Roma
I've just changed my NetBeans workflow and now I'm using Maven, just to be sure that I'm always using the latest JForex API available. I'm using the 2.7.7 API right now.
Unfortunately the problem is exactly the same as described in my first post on this thread.
An indicator calculated with Period.DAILY and Filter.WEEKENDS returns an empty array when it is calculated on any candle within a Friday, with the exception of the last candle of the day. As an example if the Strategy works with H4 candles then the only H4 Friday candle that works fine with the indicator (Period.DAILY and Filter.WEEKENDS) is the 20:00 candle.
Is anybody able to explain why this happens?


 

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