Taken from the IStrategy interface information page:
void onBar(Instrument instrument,
Period period,
IBar askBar,
IBar bidBar)
throws JFException
Called on every bar for every basic period and instrument that application is subscribed on.
In order to only work with bars of a particular instrument and period consider bar filtering:
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || period.equals(Period.ONE_HOUR)){
return;
}
//the strategy from here on only works with EURUSD ONE_HOUR bars
}
Note that the onBar method has a
Period parameter which informs you about the contents of the following
IBar parameters.
Consider SOME the possible Period values you can use for filtering described above:DAILY
FIFTEEN_MINS
FIVE_MINS
FOUR_HOURS
MONTHLY
ONE_HOUR
ONE_MIN
ONE_SEC
TEN_MINS
TEN_SECS
THIRTY_MINS
WEEKLY
Please note that the onBar is called
AFTER the completion of a bar not on the creation or
'first tick of a new bar'.
onTick calls relate to ticks accumulating with respect to the CURRENT bar (the bar that once complete will trigger a call to onBar).
Hope this helps.