Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Strategy stops when trade is entered
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=55887
Page 1 of 1

Author:  SFXbernhard [ Mon 04 Dec, 2017, 14:18 ]
Post subject:  Strategy stops when trade is entered

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)

Author:  API Support [ Tue 05 Dec, 2017, 09:31 ]
Post subject:  Re: Strategy stops when trade is entered

Please, provide code example.

Author:  SFXbernhard [ Wed 06 Dec, 2017, 02:50 ]
Post subject:  Re: Strategy stops when trade is entered

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 240 times
PlaceBidOfferBug.jfx [3.67 KiB]
Downloaded 241 times

Author:  API Support [ Wed 06 Dec, 2017, 13:45 ]
Post subject:  Re: Strategy stops when trade is entered

Will be fixed in next release.

Author:  SFXbernhard [ Thu 28 Dec, 2017, 17:53 ]
Post subject:  Re: Strategy stops when trade is entered

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.

Author:  API Support [ Thu 11 Jan, 2018, 14:13 ]
Post subject:  Re: Strategy stops when trade is entered

It has been fixed with release 3.23.2

  Page 1 of 1