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

Always profitable strategy (or ... incorrect overnight swaps in historic tester)
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=56735
Page 1 of 1

Author:  mtnfx [ Wed 26 Sep, 2018, 20:14 ]
Post subject:  Always profitable strategy (or ... incorrect overnight swaps in historic tester)

This bug is actually mentioned by SMARTFX here: https://www.dukascopy.com/swiss/english ... 728#p94070
Since I did not notice it as already reported here - I'll do it my self.
It looks like that problem is introduced in some of later versions of JForex.

Steps to reproduce

1. Open two positions with the same amount in opposite directions:
    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;
       
    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();
       
        ITick lastTick = history.getLastTick(instrument);
        engine.submitOrder("BUY", instrument, OrderCommand.BUY, 1, lastTick.getAsk(), 0, 0, 0, 0, "");
        engine.submitOrder("SELL", instrument, OrderCommand.SELL, 1, lastTick.getBid(), 0, 0, 0, 0, "");
    }

2. Run it in historic tester and see how profit is going to you ..
Expected result - in real life this use-case actually should slowly eat your money each night because loss on negative swaps is always higher than profit on positive swaps.

Image

Attachments:
allways-profitable-strategy.png [29.73 KiB]
Downloaded 589 times

Author:  API Support [ Thu 27 Sep, 2018, 08:06 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

Thanks for report. Yes, we know about this bug and now working on it.

Author:  JP7 [ Thu 25 Oct, 2018, 17:58 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

The problem is not fixed after the last platform update today.



Order_BS_STAT_X2 strategy report for EUR/USD instrument(s) from 2018-08-31 21:00:00 to 2018-09-30 20:59:59
Account Currency USD
Initial deposit 50000
Finish deposit 53659.23
Turnover 2320510
Comission 41.77
Parameters

instrument EUR/USD
slippage 2.0
amount 1.0
takeProfitPips 0
slPips 0
startBuing true
startSelling true
ordNR 1

Instrument EUR/USD

First tick time 2018-08-31 21:00:00
First tick bid value 1.15997
First tick ask value 1.16054
Last tick time 2018-09-28 20:59:56
Last tick bid value 1.16019
Last tick ask value 1.16053
Positions total 2
Closed positions 0
Orders total 2
Bought 1.00
Sold 1.00
Turnover 2320510
Comission 41.77

Opened orders:

Label Amount Direction Open price Profit/Loss at the end Profit/Loss at the end in pips Open date Comment
EURUSD01540484275476 1.000 SELL 1.162174 1644 16.4 2018-08-31 21:00:10 SELL@Market0
EURUSD11540484275478 1.000 BUY 1.158133 2057 20.6 2018-08-31 21:00:10 BUY@Market1

Closed orders:

Label Amount Direction Open price Close price Profit/Loss Profit/Loss in pips Open date Close date Comment

Processing statistic:

Function Time Calls Percent
Ticks/Bars internal processing 18s 877.25ms 1983673 39.73%
Account information calculations 16s 279.94ms 2340098 34.26%
Ticks/Bars/Account Info data writing for charts 11s 607.97ms 2045082 24.43%
Conditional orders processing 427.66ms 1983674 0.9%
onTick method calls 181.42ms 1724474 0.38%
Margin call/cut checks 84.99ms 1899073 0.18%
onBar method calls 34.24ms 320608 0.07%
onAccount method calls 18.16ms 356402 0.04%
onMessage method calls 5.82ms 46 0.01%
onStart method calls 1.54ms 1 0%
Order changes processing "on server side" 1 0%
onStop method calls 1 0%
Ticks/Bars data reads 0 0%
Historical data calls (including indicators data calls) 0 0%
Indicator calculations 0 0%
User tasks (IContext.executeTask) processing 0 0%
Other operations 0 0%
Event log:

Time Event type Event text
2018-08-31 21:00:10 Order submitted Order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0 at 0.0] submitted by the strategy
2018-08-31 21:00:10 Order submitted Order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0 at 0.0] submitted by the strategy
2018-08-31 21:00:10 Order filled Order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0 at 1.15997] filled
2018-08-31 21:00:10 Order filled Order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0 at 1.16054] filled
2018-09-03 21:00:00 Commissions Commissions [41.77]
2018-09-03 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-03 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-04 21:00:00 Commissions Commissions [0.0]
2018-09-04 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-04 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-05 21:00:00 Commissions Commissions [0.0]
2018-09-05 21:00:00 Overnights Overnight commission [2.28] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-05 21:00:00 Overnights Overnight commission [-2.49] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-06 21:00:00 Commissions Commissions [0.0]
2018-09-06 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-06 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-07 21:00:00 Commissions Commissions [0.0]
2018-09-07 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-07 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-10 21:00:00 Commissions Commissions [0.0]
2018-09-10 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-10 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-11 21:00:00 Commissions Commissions [0.0]
2018-09-11 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-11 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-12 21:00:00 Commissions Commissions [0.0]
2018-09-12 21:00:00 Overnights Overnight commission [2.28] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-12 21:00:00 Overnights Overnight commission [-2.49] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-13 21:00:00 Commissions Commissions [0.0]
2018-09-13 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-13 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-14 21:00:00 Commissions Commissions [0.0]
2018-09-14 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-14 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-17 21:00:00 Commissions Commissions [0.0]
2018-09-17 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-17 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-18 21:00:00 Commissions Commissions [0.0]
2018-09-18 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-18 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-19 21:00:00 Commissions Commissions [0.0]
2018-09-19 21:00:00 Overnights Overnight commission [2.28] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-19 21:00:00 Overnights Overnight commission [-2.49] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-20 21:00:00 Commissions Commissions [0.0]
2018-09-20 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-20 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-21 21:00:00 Commissions Commissions [0.0]
2018-09-21 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-21 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-24 21:00:00 Commissions Commissions [0.0]
2018-09-24 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-24 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-25 21:00:00 Commissions Commissions [0.0]
2018-09-25 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-25 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-26 21:00:00 Commissions Commissions [0.0]
2018-09-26 21:00:00 Overnights Overnight commission [2.28] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-26 21:00:00 Overnights Overnight commission [-2.49] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-27 21:00:00 Commissions Commissions [0.0]
2018-09-27 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-27 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-09-28 21:00:00 Commissions Commissions [0.0]
2018-09-28 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-09-28 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]
2018-10-01 21:00:00 Commissions Commissions [0.0]
2018-10-01 21:00:00 Overnights Overnight commission [0.76] pips applied to order [EURUSD01540484275476, EUR/USD, SELL, 1000000.0]
2018-10-01 21:00:00 Overnights Overnight commission [-0.83] pips applied to order [EURUSD11540484275478, EUR/USD, BUY, 1000000.0]

Attachments:
Order_BS_STAT_X2.java [4.62 KiB]
Downloaded 336 times

Author:  API Support [ Fri 26 Oct, 2018, 18:52 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

This bug took a more time than planned, we actively working on it and will try release fixed version ASAP.
We apologize for the inconvenience.

Author:  JP7 [ Tue 30 Oct, 2018, 15:01 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

Thank you !
Today after the last update all my strategies don't work no more and all of them are returning the same error message:

21:00:00 Strategy tester: java.lang.NoClassDefFoundError: com/dukascopy/api/JFXInject @ com.dukascopy.api.impl.ez.a(L:12)

Author:  Platform Support [ Wed 31 Oct, 2018, 10:22 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

Please update to version 3.4.10

Author:  JP7 [ Sun 17 Mar, 2024, 22:54 ]
Post subject:  Re: Always profitable strategy (or ... incorrect overnight swaps in historic tester)

Thank you ;)

  Page 1 of 1