just started MQL5, got a basic question on __DATETIME__

 

Hi guys,

as per topic i'm total noob on mql5. Couple of years back started mql4 but dropped it so instead of continuing i decided to give mql5 a try.

I'm trying out some basic commands and came across the __DATETIME__ so I tried printing it via the below command

Print ("DateTime is ", __DATETIME__);


The command is placed in the ontick section so it should refresh with every tick, but it kinda does and does not.

it just keep repeating the same time including the second with every tick.
shouldn't it be updated with every tick since the current time is changing?


here's the print result below. EA launched at 13:10:31, that is 1.10pm, but seconds remain 31 despite real clock moved upto 39sec

datetime


I know its not the end of the world and probably I will never use this but you know...since i'm reading and trying might aswell know what's going on and why

L

 
zelda_lee:

Hi guys,

as per topic i'm total noob on mql5. Couple of years back started mql4 but dropped it so instead of continuing i decided to give mql5 a try.

I'm trying out some basic commands and came across the __DATETIME__ so I tried printing it via the below command


The command is placed in the ontick section so it should refresh with every tick, but it kinda does and does not.

it just keep repeating the same time including the second with every tick.
shouldn't it be updated with every tick since the current time is changing?


here's the print result below. EA launched at 13:10:31, that is 1.10pm, but seconds remain 31 despite real clock moved upto 39sec


I know its not the end of the world and probably I will never use this but you know...since i'm reading and trying might aswell know what's going on and why

L

Try

Print ("DateTime is ", TimeCurrent());

Read the documentation:

Have fun

Matthias


Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
Predefined Macro Substitutions - Named Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
zelda_lee:

Hi guys,

as per topic i'm total noob on mql5. Couple of years back started mql4 but dropped it so instead of continuing i decided to give mql5 a try.

I'm trying out some basic commands and came across the __DATETIME__ so I tried printing it via the below command



have a look at what __DATETIME__  is


https://www.mql5.com/en/docs/constant_indices

Documentation on MQL5: List of MQL5 Constants
Documentation on MQL5: List of MQL5 Constants
  • www.mql5.com
List of MQL5 Constants - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
thanks. Didn't know about the timecurrent one.
Reason: