Download MetaTrader 5
To add comments, please log in or register
Use searching on MQL5.community. It is easy!
Strahinja Krstic
47
Strahinja Krstic 2009.10.08 16:47 

How can I to a datetime comparison?


In my code, I use one datetime variable, lets say:

datetime forbiddenDate;


And some time during my strategy I give to this variable a value

forbiddenDate = Time[0];


Then I want to check date to see is it good time to open


if(forbiddenDate != Time[0]){

//open

}


But it seems it doesn't work?


Can anybody help me?

Alexander
2441
Alexander 2009.10.08 17:39  

static datetime forbiddenDate;

if(forbiddenDate != Time[0]){
forbiddenDate = Time[0];

.........

}

winterss
55
winterss 2015.05.24 13:09  

I have a same problem ...

output for iTime: 915408000

But  for

datetime d1=1214870461; //D'2008.07.01 00:01:01';

Output is 1214870461, which is grater than a current date. In both cases it suppose to return unix timestamp, but it is not ...

whroeder1
13641
whroeder1 2015.05.25 16:01  
winters: it suppose to return unix timestamp, but it is not ...
It certainly is.

Mon, 04 Jan 1999 00:00:00 GMT = 915408000

Now D'2015.05.25' == 1432512000 which is greater than d1.

/
To add comments, please log in or register