Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Issues trading daily bars
 Post subject: Issues trading daily bars Post rating: 0   New post Posted: Tue 19 Jul, 2022, 08:47 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
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?


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com