Please consider the following code
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (period != this.period || instrument != this.instrument){
return;
}
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.setTimeInMillis(history.getLastTick(instrument).getTime());
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY &&
calendar.get(Calendar.HOUR_OF_DAY) == 20 && calendar.get(Calendar.MINUTE) >= 40) {
for (IOrder order : engine.getOrders(instrument)) {
order.close();
}
}
}