Hi,
I'm trying to develop a system with two simple rules.
1) Buy when previous ONE_HOUR bar is a hammer and current FIFTEEN bar closes above previous one_hour bar high.
Example:
Hour bar 7:00 is a hammer with 1.44 high
7:15 bar closes 1.4405
When I submit the order in the fifteen minute period I expect to fill the order at 7:15:04 seconds (for example)
But when I check the report.html I see than the order is filled at 7:30. All orders are filled at xx:30 minutes.
My code is the following.
TesterMain.java
client.setDataInterval(Period.ONE_MIN, OfferSide.BID,
InterpolationMethod.FOUR_TICKS, dateFrom.getTime(),
dateTo.getTime());
Strategy.java
final SimpleDateFormat sdfHourTwoDigits = new SimpleDateFormat("HH");
final SimpleDateFormat sdfMinutesTwoDigits = new SimpleDateFormat("mm");
sdfHourTwoDigits.setTimeZone(TimeZone.getTimeZone("GMT"));
sdfMinutesTwoDigits.setTimeZone(TimeZone.getTimeZone("GMT"));
@Override
public void onBar(Instrument instrument, Period period, IBar askBar,
IBar bidBar) throws JFException {
if (period.equals(Period.FIFTEEN_MINS)) {
String minutes = sdfMinutesTwoDigits.format(bidBar.getTime());
// get the first 15 minutes bar after a one_hour close
if (minutes.equals("15")) {
oneHourBar= history.getBar(instrument, Period.ONE_HOUR,
OfferSide.ASK, 0);
// this is when I expect to fill the order at xx:15:xx, not at xx:30:xx
if conditions{
engine.submitOrder(bean.getLabel(),
instrument, OrderCommand.BUY, size, 0, 5,
stopLossPrice, 0);
}
}
}
}
Can you help me please?