How to recall stop trading time

 

Hi all, is there a way to recall the stop trading time indicated in every contract specification?

In the below example 19:30. Thank you

 
Alberto Tortella: Hi all, is there a way to recall the stop trading time indicated in every contract specification? In the below example 19:30. Thank you

At first I thought it was only possible in MQL5, but after checking MQL4 documentation, it seems it is also possible in MQL4+.

Use SymbolInfoSessionTrade ...

SymbolInfoSessionQuote

Allows receiving time of beginning and end of the specified quoting sessions for a specified symbol and day of week.

SymbolInfoSessionTrade

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.

SymbolInfoSessionTrade - Market Info - MQL4 Reference
SymbolInfoSessionTrade - Market Info - MQL4 Reference
  • docs.mql4.com
SymbolInfoSessionTrade - Market Info - MQL4 Reference
 
Fernando Carreiro #:

At first I thought it was only possible in MQL5, but after checking MQL4 documentation, it seems it is also possible in MQL4+.

Use SymbolInfoSessionTrade ...

SymbolInfoSessionQuote

Allows receiving time of beginning and end of the specified quoting sessions for a specified symbol and day of week.

SymbolInfoSessionTrade

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.

Thanks a lot!

 

Could you make an example on how to recall the trading session closing time with SymbolInfoSessionTrade ?

I wouldn't expect a bool variable to recall time details.

Thank you!

SymbolInfoSessionTrade - Market Info - MQL4 Reference
SymbolInfoSessionTrade - Market Info - MQL4 Reference
  • docs.mql4.com
SymbolInfoSessionTrade - Market Info - MQL4 Reference
 
   datetime from,to;
   uint session=0;

   while(SymbolInfoSessionQuote(_Symbol,FRIDAY,session,from,to))
     {
      printf("Quoting session %i start %02i:%02i to %02i:%02i",session,from/3600,(from%3600)/60,to/3600,(to%3600)/60);
      session++;
     }

   session=0;
   while(SymbolInfoSessionTrade(_Symbol,FRIDAY,session,from,to))
     {
      printf("Trading session %i start %02i:%02i to %02i:%02i",session,from/3600,(from%3600)/60,to/3600,(to%3600)/60);
      session++;
     }
That's for FRIDAY, adjust accordingly.
 

Can I write a statement like this?

I can't verify because markets are closed.

  datetime m=TimeMinute(TimeCurrent())-15;
  
  if(SymbolInfoSessionTrade(_Symbol,FRIDAY,session,from,m))
     {
     Print("15 minutes before closing of Friday trading session");
     }

Thank you

 
Alberto Tortella #:

Can I write a statement like this?

I can't verify because markets are closed.

Thank you

No. The from and to variables are out parameters.
 

Could you make an example on how to extract the value of "to" parameter, so I can compare it with actual time?

Thanki you!