How to detect the daily trading break (23:59-00:02)?

 

Hello,

I need to stop sending orders to the server for 3 minutes during the daily trading break (23:59-00:02)? (which depends on the broker)

Market opening time is different in winter and summer, so I can not use local system time while comparing.
I can not use server time as well. I guess each broker sets its own time zone on the server side. (Am I correct about this?)
So what is the optimal way to achieve this?
Thank you.

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Position ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the...
 

What have you tried ?

Why could you not use the server time ?

 
Alain Verleyen:

What have you tried ?

Why could you not use the server time ?

Hi Alain, thank you for your answer.
I didn't try anything. I just don't know how I can detect if EA is in this time period.

if(serverTime > 11:59 && serverTime < 00:02){
    //things to do
}

I need something like above code but every broker has its own timezone. So, may be, I need to get server time zone and convert it to GMT and check it after conversion. But this time, it will change on March because of Daylight Saving.
I want above code work correctly on every broker during whole year.
Or may be there is a command to check if the broker is in "daily trading break". Ticks come but broker does not accept orders in this time period.

 
Ugur Catak: I need to stop sending orders to the server for 3 minutes during the daily trading break (23:59-00:02)? (which depends on the broker)
Why? During the break there should be no ticks. Your code shouldn't be running.
 

Hi

u can try iTime() & collaborate with TimeCurrent() at each conditions before open transactions.

i have simillar problems with dailly trade like ur conditions before.

Thanks, hope this sollution can help u bro.

 
William Roeder:
Why? During the break there should be no ticks. Your code shouldn't be running.

It seems that the EA still gets ticks during that time. My EA tried to close an order during that time. The order couldn't be closed and GetLastError() returned "0".  (The code was in onTick)

Here is also an explanation by Global Prime:

Daily Trading Break

There is a daily 3 minute break in trading from 23:59-00:02 platform time. Clients are able to see the prices streaming during this break. No orders can be placed and pre-existing orders cannot be executed during this time. This is to safeguard from positions with a Stop Loss getting hit by the potential spread spike that can occur over rollover when Liquidity Providers reset their pricing for the new trading day at 00:00 platform time (which is 5pm New York City).

https://www.globalprime.com.au/trading/market-hours

Forex Market Trading Hours - opening & closing times | Global Prime
  • www.globalprime.com.au
When the liquidity providers pricing into Global Prime switch online (Monday session start) and switch offline (Friday session end) the spreads can be wider as the liquidity providers reset and...
 
Ricky Romadona Tri Saputra:

Hi

u can try iTime() & collaborate with TimeCurrent() at each conditions before open transactions.

i have simillar problems with dailly trade like ur conditions before.

Thanks, hope this sollution can help u bro.

Thank you Ricky. I think TimeGMT() would be better to check but this time Market closes 22:00 GMT but will be changed from 22:00 GMT to 21:00 GMT during summer time. So,  Do I have to take this into account and write a code according to whether it's summer or winter, or there is a better way?

Hmm. TimeDaylightSavings()  return "0" if it is in winter time. Good to know.

TimeGMT - Date and Time - MQL4 Reference
TimeGMT - Date and Time - MQL4 Reference
  • docs.mql4.com
TimeGMT - Date and Time - MQL4 Reference
 
Ugur Catak:

Thank you Ricky. I think TimeGMT() would be better to check but this time Market closes 22:00 GMT but will be changed from 22:00 GMT to 21:00 GMT during summer time. So,  Do I have to take this into account and write a code according to whether it's summer or winter, or there is a better way?

Hmm. TimeDaylightSavings()  return "0" if it is in winter time. Good to know.

it will good bro,

making EA will spend much time to role a plan and make it better.

using a few ideas in the code will make you find which one is suitable for your EA.

It even allows you to do some new ideas from it :)

using "TimeGMT()" will be more specific, but will make some possibilities decrease. I'm not saying it's good or bad, because every EA creation will be subjective on the idea of the maker.

Reason: