Dukascopy
 
 
Wiki JStore Search Login

Strategy tester
 Post subject: Strategy tester Post rating: 0   New post Posted: Wed 22 Jan, 2014, 01:40 

User rating: 0
Joined: Thu 12 Dec, 2013, 09:24
Posts: 21
Location: Ukraine, Kyiv
Hello.

My strategy has the following code:

public void onTick(Instrument instrument, ITick tick) throws JFException {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

String currentTime = sdf.format(tick.getTime());

Date currentTickTime = new Date(tick.getTime());


Calendar calCurrentTick = GregorianCalendar.getInstance();
calCurrentTick.setTime(currentTickTime);
int yearTick = calCurrentTick.get(Calendar.YEAR);
int monthTick = calCurrentTick.get(Calendar.MONTH);
int dayTick = calCurrentTick.get(Calendar.DAY_OF_MONTH);
int hourTick = calCurrentTick.get(Calendar.HOUR_OF_DAY);
int minuteTick = calCurrentTick.get(Calendar.MINUTE);
int secondTick = calCurrentTick.get(Calendar.SECOND);

Calendar calClosestTime = GregorianCalendar.getInstance();
Date d = GetClosestNextDate(tick);
//print(d);
calClosestTime.setTime(d);
int yearClosest = calClosestTime.get(Calendar.YEAR);
int monthClosest = calClosestTime.get(Calendar.MONTH);
int dayClosest = calClosestTime.get(Calendar.DAY_OF_MONTH);
int hourClosest = calClosestTime.get(Calendar.HOUR_OF_DAY);
int minuteClosest = calClosestTime.get(Calendar.MINUTE);
int second = calClosestTime.get(Calendar.SECOND);

print("hour tick: " + Integer.toString(hourTick) + " : minute tick " + Integer.toString( minuteTick) + " secondTick=" + second );

}
The print function is declared like this:
private void print(Object o){
console.getOut().println(o);
}

Then I downloaded tick data for 2014 and for strange reason I have the following output:
2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=22
2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21
2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21
2014-01-22 00:38:22 hour tick: 2 : minute tick 0 secondTick=21

I don't know why hour is shifter in two hours. Do you have any ideas why hour is shifted in two hours? I'm especially shocked because yesterday represented code worked fine.


Attachments:
Strategy1.java [2.29 KiB]
Downloaded 138 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: Strategy tester Post rating: 0   New post Posted: Wed 22 Jan, 2014, 01:44 

User rating: 0
Joined: Thu 12 Dec, 2013, 09:24
Posts: 21
Location: Ukraine, Kyiv
but the biggest surprise is after restarting application the problem was solved and output is the following:

2014-01-22 00:43:43 hour tick: 0 : minute tick 0 secondTick=43
2014-01-22 00:43:43 hour tick: 0 : minute tick 0 secondTick=42
2014-01-22 00:43:40 hour tick: 0 : minute tick 0 secondTick=40
2014-01-22 00:43:40 hour tick: 0 : minute tick 0 secondTick=40
2014-01-22 00:43:40 hour tick: 0 : minute tick 0 secondTick=40
2014-01-22 00:43:40 hour tick: 0 : minute tick 0 secondTick=40
2014-01-22 00:43:40 hour tick: 0 : minute tick 0 secondTick=39

Does anybody can explain me why this happens, and how can I avoid such surprises during trading alive?


 
 Post subject: Re: Strategy tester Post rating: 0   New post Posted: Fri 24 Jan, 2014, 13:10 
Visual JForex expert at Dukascopy
User avatar

User rating:
Joined: Mon 22 Apr, 2013, 11:30
Posts: 604
Location: UkraineUkraine
Greetings.

Please report bug in correct forum thread:
viewforum.php?f=16


 

Jump to:  

  © 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