Dukascopy
 
 
Wiki JStore Search Login

How to synchronize time in historical tester to EET time zone
 Post subject: How to synchronize time in historical tester to EET time zone Post rating: 0   New post Posted: Sun 27 May, 2018, 10:47 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Hi everyone,

I don't know how to synchronize time in historical tester to EET time zone. I tried to do this in a different ways, but nothing works:
1) get a bars with filter weekend
2) change settings platform tester.setDataInterval() in code
3) stop print data in console when context time is lower bar time --> if ( d.getDay() > e.getDay()) { return; } else { /* do sth */ }
and other what you see in code below

Always I get data from UTC time zone. Even when I change UTC to EET in platform time zone and chart settings it does not solve the problem.

I want to use EET time zone in historical tester but I don't know how...

Those picture shows testing results my strategy code in UTC and EET time zone and it's no difference between this settings, because I get always data in UTC time zone.

This is UTC time zone in platform and chart settings

Image

This is EET time zone in platform and chart settings

Image

package jforex;

import com.dukascopy.api.*;
import com.dukascopy.api.system.IClient;

import java.util.*;

import java.util.Collections;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.dukascopy.api.system.ITesterClient;
import com.dukascopy.api.system.ITesterClient.DataLoadingMethod;

import java.text.ParseException;

public class strategy_synchronize_time implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private IChart chart;
    private ITesterClient tester;
    private IClient client;
   
    private SimpleDateFormat sdf;
    private SimpleDateFormat sdf2;
   
    ITick lastTick;
   
    public Instrument selectedInstrument = Instrument.EURUSD;
   
    Date dateFrom;
    Date dateTo;
   
    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();
        this.chart = context.getChart(selectedInstrument);

        // ================
        final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
       
        //Date dateFrom;
        //Date dateTo;
       
        try {
            dateFrom = dateFormat.parse("05/25/2018 12:00:00");
            dateTo = dateFormat.parse("05/26/2018 00:00:00");
        } catch (ParseException e) {
            e.printStackTrace();
        }       
       
        //tester.setDataInterval(DataLoadingMethod.ALL_TICKS, dateFrom.getTime(), dateTo.getTime());       
        // ================
       
        // ================
        //print( client.getAvailableInstruments() );
        //context.stop();
        // ================
       
        sdf = new SimpleDateFormat("dd");
        sdf.setTimeZone(TimeZone.getTimeZone("EET"));
       
        sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        sdf2.setTimeZone(TimeZone.getTimeZone("EET"));
    }

    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 {
        lastTick = tick;
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       
       
        //print( sdf.format( context.getTime() ) );
        //
        long prevBarTime = history.getPreviousBarStart(Period.DAILY, history.getLastTick(Instrument.EURUSD).getTime());
        List<IBar> bars = history.getBars(Instrument.EURUSD, Period.DAILY, OfferSide.BID, Filter.WEEKENDS, 1, prevBarTime, 0);
        //
        //print( " >> " + bars );
        //
        IBar dailyLastBar = history.getBar(instrument, Period.DAILY, OfferSide.BID, 0);
        print( sdf.format( dailyLastBar.getTime() ) );
       
        Date d = new Date();
        d.setTime(context.getTime());
       
        Date e = new Date();
        e.setTime(dailyLastBar.getTime());
        // !!!
        // This code result we see in the pictures
        if ( d.getDay() >  e.getDay()) {
            print( 1 + " | " + sdf2.format(dailyLastBar.getTime()) + " " + sdf2.format(context.getTime()) );
            print( dailyLastBar );
        } else {
            print( 2 + " | " + sdf2.format(dailyLastBar.getTime()) + " " + sdf2.format(context.getTime()) );
            print( " ----> " + dailyLastBar );
        }
       
       
        /*
        IBar dailyLastBar = history.getBar(instrument, Period.DAILY, OfferSide.BID, 0);
       
        Date d = new Date();
        d.setTime(context.getTime());
       
        Date e = new Date();
        e.setTime(dailyLastBar.getTime());
       
        if ( d.getDay() >  e.getDay()) {
            //return;
            print( 1 + " | " + sdf2.format(dailyLastBar.getTime()) + " " + sdf2.format(context.getTime()) );
        } else {
            print( 2 + " | " + sdf2.format(dailyLastBar.getTime()) + " " + sdf2.format(context.getTime()) );
            print( dailyLastBar );
        }
        */
 
    }
   
    public void print(Object obj) {
        console.getOut().println(obj);
    }
   
}

=====================

So, the problem is - how to set default time zone and start day time UTC to other time zone like EET. I get always only UTC data in historical tester. Maybe I'm doing something wrong... How to set default time zone in historical tester ?

Regards.


 
 Post subject: Re: How to synchronize time in historical tester to EET time zone Post rating: 0   New post Posted: Tue 29 May, 2018, 07:12 
JForex Master
User avatar

User rating:
Joined: Wed 16 Sep, 2009, 18:23
Posts: 1045
Location: Geneva, Switzerland
Day Start time zone setting in Preferences does not influence the data used in Strategy. All the data is provided in UTC.

Here is more information:
https://www.dukascopy.com/swiss/english ... one#p93428
https://www.dukascopy.com/swiss/english ... 65&t=52487


 
 Post subject: Re: How to synchronize time in historical tester to EET time zone Post rating: 0   New post Posted: Tue 29 May, 2018, 10:38 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Thanks for answer and solution. I did it like you wrote. This solution is not perfect, current candle not draw and I get price "from under" D1 candle, not from 5 min or 1H period, anyway data (for example from stochastic indicator etc) looks fine. I will continue to try to understand this... but at the moment I wanted to write that all it is ok.

In attachments:
1) screenshot of chart and platform time zone EET - Open High Low Close look Ok.
2) my strategy code

Regards.


Attachments:
strategy_synchronize_time_2.java [1.93 KiB]
Downloaded 189 times
screenshot.png [369.49 KiB]
Downloaded 170 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-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