Download MetaTrader 5
To add comments, please log in or register
Do you have questions on how to turn your idea into reality? Ask them on the Forum!
Robert Mihali
5868
Robert Mihali 2014.08.15 09:31 

hello everybody, 

I want to programm an EA, that opens at a certain time (which the user can define) pending orders and I have problems with this date and time functions like TimeCurrent().

Until now I have this: 

extern datetime time = D'2014.08.15 11:10:00'; 

and now I want to compare this time with the TimeCurrent() to open a pending order. The Question is: what argument should I put in the bracket? I don't really understand the definition in the documentary

https://docs.mql4.com/dateandtime/timecurrent 

 

The next question I have is: Is there the possibility to 'do math' with this datetime. For example if I have again the time defined like above, how can I define NewTime=time +3minutes ??

It would be very helpfull if somebody can answer. Thanks a lot

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.08.15 10:17  
cornesti:

hello everybody, 

I want to programm an EA, that opens at a certain time (which the user can define) pending orders and I have problems with this date and time functions like TimeCurrent().

 

You need to understand what a datetime  (<---- link, please click me  ) type variable is . . .  ". . .   as the number of seconds elapsed since January 01, 1970"

 

If you want the datetime 3 minutes from now . . . TimeCurrent() + 3 * PERIOD_M1 * 60 

whroeder1
13607
whroeder1 2014.08.15 12:43  

cornesti: The Question is: what argument should I put in the bracket? 

The next question I have is: Is there the possibility to 'do math' with this datetime.

  1. What bracket?
  2. Like this
    #define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600
    int      TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent();
       return( when % HR2400 ); }
    datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent();
       return( when - TimeOfDay(when) ); }
    //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent();
    //   return(DateOfDay(when) + HR2400); }
    //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent();
    //   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1);
    //   return( iTime(NULL, PERIOD_D1, iD1) ); }
Robert Mihali
5868
Robert Mihali 2014.08.15 12:54  

thanks a lot guys, now I know how to do it. With the bracket I meant the one after TimeCurrent(). But it's the same think as in Symbol(), doesn't need any input arguments.

whish you a nice weekend 

whroeder1
13607
whroeder1 2014.08.16 12:36  
cornesti: With the bracket I meant the one after TimeCurrent(). 
Choose your words better
CharacterUS EnglishUK EnglishIndia
()ParenthesesBraces, round brackets, curved brackets, oval brackets
[]BracketsSquare Brackets
{}BracesCurly bracketsflower bracket
<>Angle brackets (or chevrons)
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.08.16 15:53  
WHRoeder:
cornesti: With the bracket I meant the one after TimeCurrent(). 
Choose your words better
CharacterUS EnglishUK EnglishIndia
()Parentheses
[]BracketsSquare Brackets
{}BracesCurly bracketsflower bracket
<>Angle brackets (or chevrons)

( ) these are also known as Brackets in my experience of UK English . . . almost 49 years ;-)
/
To add comments, please log in or register