Page 1 of 1

MQL4 how get the time from 00:00:00 (day start time)

Posted: Wed Feb 15, 2017 7:44 am
by baraozemo
Hi,

(mt5) 

I need to get the datetime 00:00 from the current day..
is this correct? (is not working)...

datetime start=D'00:00:00'

Re: MQL4 how get the time from 00:00:00 (day start time)

Posted: Wed Feb 15, 2017 7:52 am
by mladen
baraozemo wrote:Hi,

(mt5) 

I need to get the datetime 00:00 from the current day..
is this correct? (is not working)...

datetime start=D'00:00:00'
You are missing the day part in that format
You can not do that that way. Try like this :

Code: Select all

   datetime start = StringToTime(TimeToString(TimeCurrent(),TIME_DATE));

or use the specific time for specific bar instead of the TimeCurrent() to get day part for that bar

Re: MQL4 how get the time from 00:00:00 (day start time)

Posted: Wed Feb 15, 2017 10:42 pm
by baraozemo
yes, this solved..

datetime start = StringToTime("00:00:00");

Re: MQL4 how get the time from 00:00:00 (day start time)

Posted: Thu Feb 16, 2017 7:17 pm
by mladen
baraozemo wrote:yes, this solved..

datetime start = StringToTime("00:00:00");
That way the date might be different from broker time (if I am not mistaken), but try it out