Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Strange indicators.ma() behavior - ArrayIndexOutOfBoundsException
 Post subject: Strange indicators.ma() behavior - ArrayIndexOutOfBoundsException Post rating: 0   New post Posted: Thu 26 Mar, 2020, 15:02 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 39

I have the following code:
package jforex.simpletests;

import com.dukascopy.api.*;
import com.dukascopy.api.util.DateUtils;

public class TestEmptySMA implements IStrategy {
    @Configurable(value="SMAPeriods", stepSize=1)
    public int SMAPeriods = 30;

    public void onStart(final IContext context) throws JFException {
        double[] SMAs = new double[0];
        try {
            SMAs = context.getIndicators().ma(
                    DateUtils.parse("2020-01-08 00:00:00:000"),
        } catch (Exception e) {
        context.getConsole().getOut().println(String.format("%.5f;", SMAs[0]));


    public void onAccount(IAccount account) throws JFException {}

    public void onMessage(final IMessage message) throws JFException {}

    public void onStop() throws JFException {}

    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    public void onBar(final Instrument instrument, final Period period, final IBar askBar, final IBar bidBar) {}

SMAPeriods = 10
it works fine, but for
SMAPeriods = 30
it returns empty SMAs table, what generates
13:58:25 java.lang.ArrayIndexOutOfBoundsException: 0 @ jforex.simpletests.TestEmptySMA.onStart(TestEmptySMA.java:30)

I do not know if that is the cause, but it was working fine before JForex 3.6.14. What might be the cause? Should I handle this in different way now?

Best regards,

File comment: Issue demonstration code
TestEmptySMA.java [1.53 KiB]
Downloaded 149 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: Strange indicators.ma() behavior - ArrayIndexOutOfBoundsException Post rating: 0   New post Posted: Tue 26 May, 2020, 17:34 
User avatar

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

That issue was fixed in JForex 3.6.18

Kind regards.


Jump to:  

  © 1998-2011 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