detect the London opening sission

 
Hello

I am looking for the way that I can detect the London opening sission ..
How to detect the opening of markets? Could I call then the Hour() function ?

//---
void OnTick()
{

  if ( Hour() == 10 ) ....   //London
  if ( Hour() == 0  ) ....    //Tokyo
  if ( Hour() == 15 ) ....   //New York

}




Does the above script detect the opening session correctly? What about the winter timing
 

Dear Mohammad,

nope this won't work. 

Please read the documentation: https://docs.mql4.com/dateandtime/hour 

Hour() returns the last known server time which means that it returns different values for different brokers. 

Check the Date and Time possibilities for MQL4 in detail: https://docs.mql4.com/dateandtime 

And if you google for GMT and DST codes for mql4 you'll find a bunch of examples.

Best regards

Daniel 

Hour - Date and Time - MQL4 Reference
Hour - Date and Time - MQL4 Reference
  • docs.mql4.com
Hour - Date and Time - MQL4 Reference
 

What I do, ...

Read server time ... 

Add/sustract GMY difference from the EA input external settings ... 

By the way, if you search for 1MinuteDaily indicator, you will find ready code there. 

 
So, should i use the TimeGMT() function?



//---
void OnTick()
{

  if ( TimeGMT() == 7 ) ....        //London
  if ( TimeGMT() == 21  ) ....    //Tokyo
  if ( TimeGMT() == 12 ) ....     //New York

}


But i beleive that there is a *.mqh Library which is managing this kind of programming
Reason: