Dukascopy
 
 
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.

Strategy stops when trade is entered
 Post subject: Strategy stops when trade is entered Post rating: 0   New post Posted: Mon 04 Dec, 2017, 14:18 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
I found a null pointer exception bug in the JForex code, see the following console entries.
Problem exists on latest JForex 3.2.19 and 2.45.77
Please fix this.

2017-12-04 12:16:20.676 ERROR o - 
java.lang.NullPointerException
   at com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1153)
   at com.dukascopy.api.impl.execution.o.call(L:108)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at com.dukascopy.api.impl.execution.f$a.f(L:904)
   at com.dukascopy.api.impl.execution.f$a.run(L:926)
   at java.lang.Thread.run(Thread.java:745)
2017-12-04 12:16:20.678 ERROR o -
java.lang.NullPointerException
   at com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1153)
   at com.dukascopy.api.impl.execution.o.call(L:108)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at com.dukascopy.api.impl.execution.f$a.f(L:904)
   at com.dukascopy.api.impl.execution.f$a.run(L:926)
   at java.lang.Thread.run(Thread.java:745)
2017-12-04 12:16:20.685 ERROR h$b - Exception thrown while running onMessage method: null
java.lang.NullPointerException
   at com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1153)
   at com.dukascopy.api.impl.execution.o.call(L:108)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at com.dukascopy.api.impl.execution.f$a.f(L:904)
   at com.dukascopy.api.impl.execution.f$a.run(L:926)
   at java.lang.Thread.run(Thread.java:745)
2017-12-04 12:16:20.685 ERROR h$b - Exception thrown while running onMessage method: null
java.lang.NullPointerException
   at com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1153)
   at com.dukascopy.api.impl.execution.o.call(L:108)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at com.dukascopy.api.impl.execution.f$a.f(L:904)
   at com.dukascopy.api.impl.execution.f$a.run(L:926)
   at java.lang.Thread.run(Thread.java:745)


 
 Post subject: Re: Strategy stops when trade is entered Post rating: 0   New post Posted: Tue 05 Dec, 2017, 09:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please, provide code example.


 
 Post subject: Re: Strategy stops when trade is entered Post rating: 0   New post Posted: Wed 06 Dec, 2017, 02:50 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
sure

/*     
 * This is a test programm only, do not use for trading!
 * It checks submitOrder
 * method of IEngine
 * At current JForex version it produces a strategy crash
 *
 * (c) Stash GmbH Muenchen / Germany, December 5th 2017
 *     www.stash.de
 *     Author: Bernhard Schicht
 *     Email: [email protected]
 */



package jforex;

import java.util.*;
import com.dukascopy.api.IEngine.*;
import com.dukascopy.api.*;

public class PlaceBidOfferBug implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
   
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.context = context;
        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
    }

    public void onAccount(IAccount account) throws JFException {
        Set<Instrument> subscribe = new HashSet<Instrument>();   
        subscribe.add(Instrument.USDTRY);
        context.setSubscribedInstruments(subscribe, true);
   
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }
    private boolean runOnce = false;
    private ITick tick = null;
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        this.tick = tick;
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (instrument != Instrument.USDTRY) return;
        if (period != Period.ONE_MIN) return;
        if (tick == null) return;
        if (runOnce) return;
                   
        runOnce = true;
        // place bid order 1 pip above current tick when bar starts
        IOrder longOrder = engine.submitOrder(
                "Test_"+System.currentTimeMillis(),instrument,
                OrderCommand.PLACE_BID,
                0.01, tick.getBid()+1D*instrument.getPipValue(),
                20, askBar.getLow()-200D*instrument.getPipValue(),
                askBar.getHigh()+5D*instrument.getPipValue(), 0L);
    }
}


You fill find errors in the Java console and in the Messages tab
2017-12-06 01:48:00 java.lang.NullPointerException @ com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1153)


Attachments:
PlaceBidOfferBug.java [2.25 KiB]
Downloaded 235 times
PlaceBidOfferBug.jfx [3.67 KiB]
Downloaded 237 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: Strategy stops when trade is entered Post rating: 0   New post Posted: Wed 06 Dec, 2017, 13:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Will be fixed in next release.


 
 Post subject: Re: Strategy stops when trade is entered Post rating: 0   New post Posted: Thu 28 Dec, 2017, 17:53 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
I tested this serious bug on the new JForex release 3.22.2

16:50:01 java.lang.NullPointerException @ com.dukascopy.api.impl.connect.PlatformOrderImpl.c(L:1297)

It is still not working!
Please fix this bug asap as this hinders any automatic trading strategy having place bid/offer orders of proper working.

This needs a higher priority on your side. Customers could lose money when a strategy gets stopped by this bug.


 
 Post subject: Re: Strategy stops when trade is entered Post rating: 0   New post Posted: Thu 11 Jan, 2018, 14:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It has been fixed with release 3.23.2


 

Jump to:  

cron
  © 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