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.

Timing problem in JForex3 at full Historical Tester speed, missed trade
 Post subject: Timing problem in JForex3 at full Historical Tester speed, missed trade Post rating: 0   New post Posted: Fri 15 Dec, 2017, 03:20 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
There is a flaw or timing problem in JForex3 Historical Tester. It misses trades at full speed in Visual mode.
Please run the following demonstration program in Historical Tester
from 06:40 12.12.2017 to 00:00 13.12.2017
in Visual mode
Show messages
It should place 2 entries at 12-12-2017 06:49:31.266 GMT
1) at full speed --> it misses the 2nd trade
2) at a slower speed than full speed, e.g.6x --> it enters both trades
3) uncomment "// this gets a fill" in the code and try it at full speed --> it enters both trades. The difference is the different TP only.
4) retry not in Visual mode --> it enters both trades
5) retry in JForex2. It works there 100%, even at full speed.
It happens in Historical Tester at full speed only. I tested this in Forward run without a problem.

Bug found in JForex 3.2.21

/*     
 * This is a test programm only, do not use for trading!
 * It checks submitOrder
 * method of IEngine
 *
 * (c) Stash GmbH Muenchen / Germany, December 5th 2017
 *     https://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 AnotherPlaceBidOfferBug implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;   
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.context = context;
    }
    public void onAccount(IAccount account) throws JFException {
        Set<Instrument> subscribe = new HashSet<Instrument>();   
        subscribe.add(Instrument.EURUSD);
        context.setSubscribedInstruments(subscribe, true);   
    }
    public void onMessage(IMessage message) throws JFException {
        console.getOut().println("<html><font color=\"#2020FF\">message = "+message+"</font>");
    } 
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        // at  12-12-2017 06:49:31.266 GMT 
        if (tick.getTime() == 1513061371266L){
            // place bid order
            IOrder longOrder = engine.submitOrder(
                    "Test_"+System.currentTimeMillis(),instrument,
                    OrderCommand.PLACE_BID,
                    0.01, 1.17780, 0, 1.17681, 1.17831, 0L);                     
            context.getConsole().getOut().println("longOrder = " +longOrder);
           
            // place another bid order
            IOrder anotherLongOrder = engine.submitOrder(
                    "AnotherTest_"+System.currentTimeMillis(),instrument,
                    OrderCommand.PLACE_BID,                                         
                    // 0.02, 1.17780, 20, 1.17681, 1.17831, 0L);    // this gets a fill
                       0.02, 1.17780, 0, 1.17681, 1.17981, 0L);    // this does NOT get filled!   
           
            context.getConsole().getOut().println("anotherLongOrder = " +anotherLongOrder);
        }
    }   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {    }
    public void onStop() throws JFException { }   
}


Image
Image


Attachments:
File comment: should be 2 instead of 1 position in JForex3
JForex3.jpg [39.32 KiB]
Downloaded 343 times
File comment: it works in JForex2
JForex2.jpg [35.44 KiB]
Downloaded 330 times
File comment: source
AnotherPlaceBidOfferBug.java [2.41 KiB]
Downloaded 196 times
File comment: compiled version
AnotherPlaceBidOfferBug.jfx [3.66 KiB]
Downloaded 190 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: Timing problem in JForex3 at full Historical Tester speed, missed trade Post rating: 0   New post Posted: Tue 19 Dec, 2017, 09:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We were unable to reproduce this. Both orders open correctly. Are there any orders in the console?


 
 Post subject: Re: Timing problem in JForex3 at full Historical Tester speed, missed trade Post rating: 0   New post Posted: Tue 19 Dec, 2017, 10:11 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
Have you tried this in the current Historical Tester at full speed?
It always opens only 1 position, see attached screen shot.

Image

Here I was trying to correct the problem by executing the submit orders in own tasks. Same result. :(

            Future <Double> fut = context.executeTask(new Callable<Double>() {
                public Double call() {
                    try{
                        // place bid order
                        IOrder longOrder = engine.submitOrder(
                            "Test_"+System.currentTimeMillis(),instrument,
                            OrderCommand.PLACE_BID,
                            0.02, 1.17780, 0, 1.17681, 1.17831, 0L);                     
                        context.getConsole().getOut().println("longOrder = " +longOrder);
                    }
                    catch(Exception e){}
                    return new Double(0D);
                }
            });
           
            Future <Double> fut2 = context.executeTask(new Callable<Double>() {
                public Double call() {
                    // place another bid order
                    try{
                        IOrder anotherLongOrder = engine.submitOrder(
                                "AnotherTest_"+System.currentTimeMillis(),instrument,
                                OrderCommand.PLACE_BID,                                         
                                // 0.02, 1.17780, 20, 1.17681, 1.17831, 0L);    // this gets a fill
                                  0.02, 1.17780, 0, 1.17681, 1.17981, 0L);    // this does NOT get filled!   
                       
                        context.getConsole().getOut().println("anotherLongOrder = " +anotherLongOrder);   
                     
                    }
                    catch(Exception e){}
                    return new Double(0D);
                }
            });


Attachments:
171218historical_tester.jpg [148.23 KiB]
Downloaded 332 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: Timing problem in JForex3 at full Historical Tester speed, missed trade Post rating: 0   New post Posted: Fri 22 Dec, 2017, 11:16 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
But the message on charts shows 1 closed AND 1 open position.


 
 Post subject: Re: Timing problem in JForex3 at full Historical Tester speed, missed trade Post rating: 0   New post Posted: Fri 22 Dec, 2017, 11:39 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
sorry, my mistake. Please delete this thread


 

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