Last Activity Time of EA

 

Hi, writing my first EA, which is also my first try in MQL language.
Have been programming in other languages for a few years now.

The question is : How I can calculate the time difference, since the last time my EA was used ?
let's say , I don't want the EA to start , if it's less than 12 hours since its last activity.

I've decided this (based on what I read in Documents and some forum search) :

  1. Set a global variable using GlobalVariableSet() function,to save the current timedate value. (in OnTimer() event, i.e the GV content gets updated each minute)
  2. Get he Global variable content at the very start of my EA.
  3. compare the retrieved value against the current time.
    (which is strange but probably doable, cuz you gotta retrieve that timedate type and save it in a double variable. and then compare it against another timedate variable !)

I know timedate variables are nothing more than a number of seconds from a special time. but is the following the way to do the third step ?
Time_Difference = timedate CurrentTimeNow - double GV_LastTime

Please someone comment on how to do it? specially the third step.
and if there's a better approach, please

 
GV_LastTime = (int) TimeCurrent()
:
Time_Difference = TimeCurrent() - (DateTime) GV_LastTime;
 
whroeder1:
So the (timedate) type casting does the trick :)
Thanks for the hint.

Also, what does it mean that the TimeCurrent() function returns the Server time ?
does that mean it's possible for the EA to make mistakes in time difference calculation, once the broker is changed ?
just asking outa curiosity.
 
Reason: