Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3544 IHistory.getBars() is buggy in new DEMO
 Post subject: JFOREX-3544 IHistory.getBars() is buggy in new DEMO Post rating: 0   New post Posted: Mon 20 Feb, 2012, 12:25 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
There is a bug in function IHistory.getBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter)
and the new DEMO Dukascopy ver. 2.14.24.3
If I need 10 bars from now back on EURUSD, Period.TEN_SECS I get different results on DEMO and on LIVE:

Here comes an example printout:

DEMO Dukascopy ver. 2.14.24.3
2012-02-20 11:18:46 8: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:18:50 GMT
2012-02-20 11:18:46 7: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:18:30 GMT
2012-02-20 11:18:46 6: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:18:20 GMT
2012-02-20 11:18:46 5: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:18:10 GMT
2012-02-20 11:18:46 4: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:18:00 GMT
2012-02-20 11:18:46 3: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:17:50 GMT
2012-02-20 11:18:46 2: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:17:40 GMT
2012-02-20 11:18:46 1: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:17:30 GMT
2012-02-20 11:18:46 0: EUR/USD : barsList.size() = 9, barsBack = 10, bartime = 20 Feb 2012 11:17:20 GMT
2012-02-20 11:18:46 currentbartime = 20 Feb 2012 11:18:50 GMT

LIVE Dukascopy ver. 2.12.30
2012-02-20 11:18:32 9: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:50 GMT
2012-02-20 11:18:32 8: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:40 GMT
2012-02-20 11:18:32 7: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:30 GMT
2012-02-20 11:18:32 6: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:20 GMT
2012-02-20 11:18:32 5: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:10 GMT
2012-02-20 11:18:32 4: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:18:00 GMT
2012-02-20 11:18:32 3: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:17:50 GMT
2012-02-20 11:18:32 2: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:17:40 GMT
2012-02-20 11:18:32 1: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:17:30 GMT
2012-02-20 11:18:32 0: EUR/USD : barsList.size() = 10, barsBack = 10, bartime = 20 Feb 2012 11:17:20 GMT
2012-02-20 11:18:32 currentbartime = 20 Feb 2012 11:18:50 GMT


The second line with bartime = 20 Feb 2012 11:18:40 GMT is missing in DEMO!
Please also try different barsBack (=3 gives only 1 line in DEMO and 3 lines in LIVE !!) and periods.


Here is the code
/*     
 * This is a test programm only, do not use for trading!
 * It checks the IHistory.getBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter) bug
 *
 * (c) Stash GmbH München
 *     www.stash.de
 *     Author: Bernhard Schicht
 *     Email: [email protected]
 */
 

package jforex;

import com.dukascopy.api.*;
import com.dukascopy.api.Filter;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.IUserInterface;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import java.util.*;
import java.util.Calendar;
import java.util.TimeZone;

public class StrategyTestBasicPeriod implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
   
    @Configurable("Instrument")                          public Instrument instr = Instrument.EURUSD;
    @Configurable("Bars back")                           public int barsBack = 10;
    @Configurable("Period")                              public Period checkPeriod = Period.TEN_SECS;
   
    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 {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {       
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (period != checkPeriod) return;
        if (instr != instr) return;
        List<IBar> barsList = null;
        long currentbartime = 0L;
        OfferSide os= OfferSide.BID;
        try{           
            long time = history.getLastTick(instr).getTime();
            currentbartime = history.getBarStart(period,  time);
            barsList = history.getBars(instr, period, os, Filter.NO_FILTER, barsBack, currentbartime, 0);
           
           
            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
            cal.setTimeInMillis(currentbartime);
            p("currentbartime = "+cal.getTime().toGMTString());
            for (int t = 0 ; t < barsList.size() ; t++){
                cal.setTimeInMillis(barsList.get(t).getTime());
                p(t+": "+instr.toString()+" : barsList.size() = "+barsList.size()+", barsBack = "+barsBack+", bartime = "+cal.getTime().toGMTString());
            }
        }
        catch (Exception e){
            e.printStackTrace(console.getErr());
        }
    }
   
    public void p(String text){
        console.getOut().println(text);
    }
    public void pErr(String text){
        console.getErr().println(text);
    }

}


Please correct asap!


Attachments:
StrategyTestBasicPeriod.java [3.47 KiB]
Downloaded 320 times
StrategyTestBasicPeriod.jfx [4.29 KiB]
Downloaded 313 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.
 

Jump to:  

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