Hi all,
I'm trying to write a strategy based on daily bars:
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
// validate period
if (period != Period.DAILY) {
return;
}
...
However, the daily bars that I receive from the JForex platform are from 00:00 to 00:00 the next day. I see two possible problems with this:
#1
Sometimes when I receive the daily bar the market is closed and I'm not able to open/close any orders.
Time Messages
2022-03-20 00:00:00 ORDER_SUBMIT_REJECTED - System offline order: CANCELED BUY 1.0E-6 @ 0.0
The small amount is because the instrument in this test is
USA500.IDX/USD.
It would of course be possible to use
// validate open market
if (context.getDataService().isOfflineTime(bidBar.getTime() + period.getInterval(), instrument)) {
return;
}
to validate if the market is currently open. However, the problem is still that I'll receive the daily bars once the market is closed.
#2
I might not want a daily bar ranging from 00:00 to 00:00 the next day. Instead I'm thinking that perhaps it's better to adapt it to the opening hours of the NYSE or similar (since the NYSE is open from Monday through Friday 9:30 a.m. to 4:00 p.m. Eastern time).
Anyone here who is trading daily bars and have thought about these issues?