The following strategy when run prints first and last ticks. When running from 2009.06.23 to 2009.07.04 it outputs
09:23:40 Last tick: 2009-07-03 21:00:00 020
09:23:07 First tick: 2009-06-23 00:00:00 351
Can you confirm that?
package jforex;
import java.util.*;
import java.text.*;
import com.dukascopy.api.*;
public class PrintFirstLastTick implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private ITick lastTick;
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 {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
console.getOut().println("Last tick: " + format.format(lastTick.getTime()));
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (lastTick == null) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
console.getOut().println("First tick: " + format.format(tick.getTime()));
}
lastTick = tick;
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}