How to determine exact moment of market open after the weekend or holiday ?

 
Your broker time ... use TimeCurrent()
 
sorasit46: What function that indicates the market is start open ?
None, you have to make one. start a function when the market is closed? - MQL4 forum
 
thank you
 
sorasit46:

What function that indicates the market is start open ?

thank you


If you looking for a time a GAP appears after a free day it is easier to see the time between opening new candel (0) and closing candel (1) so don't look to the days the candels appear, but simply look to the time of opening and closing candel.
The difference between them must be a day. A day has 24 hours, each hour 60 minutes, and 60 seconds. (That makes a day 86400 seconds) With the function datetime (this is a integer) you can symply see the difference between two candels in time. This datetime is counting seconds from 1970 till the moment of now, and gives so a value of a date. So if you wanna know the time difference between two moments you take those two moments datetime, and like a sum you see the difference in seconds. This way I find the moment the EA had to look if there's a gap....

The Gapfactor is used to get the right gapspace. and is 10000 (for 4 or 5 digits) currencies,
or 100 for (2 or 3 digits) currencies...

bool GapOrder(){

datetime current_time=iTime(Symbol(), 0, 0);
datetime past_time=iTime(Symbol(),0,1);

  if((current_time-past_time)>86399)
  {
   target1=iOpen(NULL,0,0);
   target2=iClose(NULL,0,1);
   target=(target1-target2)*Gapfactor;
   if (!(target==Gapspace))
     {
      Gapspace=target;
      GapOrder=1;
     }
  }
}  

This is the function i created for a GAP EA 3 years ago it tells you also

How to determine exact ........

 
deVries:
datetime current_time=iTime(Symbol(), 0, 0);
datetime past_time=iTime(Symbol(),0,1);
if((current_time-past_time)>86399)
The question was start of the new week. Your test will also trigger after Christmas and other market holidays. (There's also no need for a function call when you can use the predefines.)
bool isNewWeek = TimeDayOfWeek(Time[0]) < TimeDayOfWeek(Time[1]);
 
WHRoeder:
The question was start of the new week. Your test will also trigger after Christmas and other market holidays. (There's also no need for a function call when you can use the predefines.)


Question ??? look to the title of this topic.

correct that there is no need for a function call but this was what i created three years ago for an EA that time <link removed> i explained in my posting

just gave this as my solution how to handle question of this topic

 
I use my broker time. Simple as that.
 
deysmacro:
I use my broker time. Simple as that.

how do you use broker time....
Close your metatrader at market close and restart it....

 

Yes. Use TimeCurrent().

Using broker time is much easier since, well, everything you do must be tallied to broker time as well. In my case that is.

Reason: