Download MetaTrader 5

Datetime comparison

To add comments, please log in or register
Strahinja Krstic
47
Strahinja Krstic  

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  

static datetime forbiddenDate;

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

.........

}

winterss
148
winterss  

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
14779
whroeder1  
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