It is described here
https://www.dukascopy.com/wiki/#History_barsTo get the currently forming bar time parameter of
getBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter)
must be equal to the start time of currently forming candle.
public void onTick(Instrument instrument, ITick tick) throws JFException {
long lastBarStart = history.getBarStart(Period.ONE_HOUR, tick.getTime() );
print("last bar start", lastBarStart);
List<IBar> bars = history.getBars(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, Filter.NO_FILTER, 3, lastBarStart, 0);
for(IBar bar : bars) {
print(bar);
}
}
See a full example in the attachment.