Hello,
Yes you can archive this by following this:
package yourpackage.test;
import com.dukascopy.api.*;
import java.util.List;
public class MyStrategy implements IStrategy {
IContext context;
IHistory history;
IConsole console;
ITick tick;
long tickTime; // get the time of last tick
long barStartTime;
private Instrument instrument = Instrument.EURUSD;
@Override
public void onStart(IContext context) throws JFException {
this.context = context;
this.history = context.getHistory();
this.console = context.getConsole();
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {
tick = history.getLastTick(instrument);
tickTime = tick.getTime();
barStartTime = history.getBarStart(Period.ONE_MIN, tickTime);
List<IBar> resultbars = history.getBars(instrument, Period.ONE_MIN, OfferSide.BID, Filter.NO_FILTER, 1, barStartTime, 0);
IBar bar = resultbars.get(0);
}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
@Override
public void onMessage(IMessage message) throws JFException {
}
@Override
public void onAccount(IAccount account) throws JFException {
}
@Override
public void onStop() throws JFException {
}
}
For more details:
Click HereGood luck and have a nice day!