Tomorrow is Trading Day or Off Day ? How to Tell ?

 

Hi everybody, I used to basket close all the open trades on Friday 23:30 automatically by setting TimeDayOfWeek(TimeCurrent())==5 in my EA.

The problem now is what if today is Thursday and tomorrow Friday is a holiday (off-trading day), is there a command to detect automatically whether a broker's tomorrow is a trading or non-trading day ?

Hope you can advise, thanks

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
To obtain the current market information there are several functions: SymbolInfoInteger() , SymbolInfoDouble() and SymbolInfoString() . The first...
 
Chin Min Wan:

Hi everybody, I used to basket close all the open trades on Friday 23:30 automatically by setting TimeDayOfWeek(TimeCurrent())==5 in my EA.

The problem now is what if today is Thursday and tomorrow Friday is a holiday (off-trading day), is there a command to detect automatically whether a broker's tomorrow is a trading or non-trading day ?

Hope you can advise, thanks

You could periodically, e.g. every minute, open a "far" pending order and delete it immediately again.
If the order failed you can check its status (MARKET CLOSED).

Good luck.

 
Soewono Effendi #:

You could periodically, e.g. every minute, open a "far" pending order and delete it immediately again.
If the order failed you can check its status (MARKET CLOSED).

Good luck.

Hi Soewono, thanks.

I'm learning coding now, could you please provide codes how to "convert" the "MARKET CLOSED" of pending order into action ?

As I said, I plan to basket close all open orders on every Friday at 23:30. Presuming there is pending order triggers (pending order's date is next day Friday) on Thursday at 23:29 and the feedback status is "MARKET CLOSED", therefore the EA must execute basket close of all open orders on Thursday at 23:30 instead of Friday (non-trading day), could you please help in codes ? Appreciated ...

 
Soewono Effendi #: You could periodically, e.g. every minute, open a "far" pending order and delete it immediately again.

If the order failed you can check its status (MARKET CLOSED).

That will not work for OP. He wants to know the day before to close trades before.

 
William Roeder #:

That will not work for OP. He wants to know the day before to close trades before.

Hi William, thanks, do you have the solution (in terms of codes) to detect a broker's tomorrow whether is a trading or non-trading day ? Thanks

 
Chin Min Wan #: Hi William, thanks, do you have the solution (in terms of codes) to detect a broker's tomorrow whether is a trading or non-trading day ? Thanks

No, the MetaTrader system does not convey that type of information. It only provides information on the generalised session times.

Information about any special dates such as holidays or session changes, is usually provided by the broker via an external method, such as emails, push messages or other methods.

 
Fernando Carreiro #:

No, the MetaTrader system does not convey that type of information. It only provides information on the generalised session times.

Information about any special dates such as holidays or session changes, is usually provided by the broker via an external method, such as emails, push messages or other methods.

Noted with thanks
 

There is a possibility if you are working on the EA for MT5. Use the Economic Calendar library to retrieve the events for the week and search for Event Type as CALENDAR_TYPE_HOLIDAY. I suppose it will be as your broker's holidays. 

Simpler option will be to store the holidays in a file and check in your code.

Hope one of them works for you.

Cheers,

Economic Calendar - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

 
Keni Chetankumar Gajanan - #:

There is a possibility if you are working on the EA for MT5. Use the Economic Calendar library to retrieve the events for the week and search for Event Type as CALENDAR_TYPE_HOLIDAY. I suppose it will be as your broker's holidays. 

Simpler option will be to store the holidays in a file and check in your code.

Hope one of them works for you.

Cheers,

Economic Calendar - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Thanks. At this moment, I only understand mql4, but in future I'll study mql5.
 
@Keni Chetankumar Gajanan - - #: There is a possibility if you are working on the EA for MT5. Use the Economic Calendar library to retrieve the events for the week and search for Event Type as CALENDAR_TYPE_HOLIDAY. I suppose it will be as your broker's holidays.  Simpler option will be to store the holidays in a file and check in your code.Hope one of them works for you.

Economic Calendar - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Please note that this topic is in the MQL4 section. Your main solution is for MQL5, not MQL4. MQL4 does not have built-in "Economic Calender" functionality.