Print statement prints milliseconds but no milliseconds on datetime in MQL5

 

I am a new user of MQL5.

I am faintly shocked that datetime doesn't have millisecond resolution.

My use case is that I want to know the frequency that a quote is updated in the OnTick handler. I have a lot of other code outside MQL5 that uses millisecond resolution.

Obviously one is able to access SYSTEMTIME struct in kernel32.dll but unable to compare epoch time in seconds.

There is also the FILETIME struct in the windows API which returns Ticks but that is using BIGINTEGER and it seems we're getting quite off piste just to do a millisecond timestamp which this is already produced by Print.

What I want is Epoch time with ms resolution.  Is there a way to get this ?

Given the documentation talks about converging similarity with C++ for MQL5 are there any ways to introduce millisecond resolution or plans in the pipeline to introduce it. 

Any way of lodging a request with the development roadmap ? 

Thanks

 
Iain Bell:

I am a new user of MQL5.

I am faintly shocked that datetime doesn't have millisecond resolution.

My use case is that I want to know the frequency that a quote is updated in the OnTick handler. I have a lot of other code outside MQL5 that uses millisecond resolution.

Obviously one is able to access SYSTEMTIME struct in kernel32.dll but unable to compare epoch time in seconds.

There is also the FILETIME struct in the windows API which returns Ticks but that is using BIGINTEGER and it seems we're getting quite off piste just to do a millisecond timestamp which this is already produced by Print.

What I want is Epoch time with ms resolution.  Is there a way to get this ?

Given the documentation talks about converging similarity with C++ for MQL5 are there any ways to introduce millisecond resolution or plans in the pipeline to introduce it. 

Any way of lodging a request with the development roadmap ? 

Thanks

That's true and really frustrating, no millisecond time resolution in MQL5.

 
ulong startTime = GetMicrosecondCount();
 
MqlTick tick;
if(SymbolInfoTick(_Symbol,tick))
 {
   int ms=tick.time_msc%1000;
   PrintFormat("%s,%03d",TimeToString(tick.time,TIME_SECONDS),ms);
 }
In MQL 5, MqlTick contains the tick time in milliseconds. datetime is Unix style, number of seconds since 1970.
 
Iain Bell: ... My use case is that I want to know the frequency that a quote is updated in the OnTick handler. ...

probably also useful in in this context is the current tick time with millisec precision:

SymbolInfoTick(_Symbol,tick);
long tick_time_msc=tick.time_msc;

so you could either use

- the msc time difference between current and precious tick.time_msc or

- the microsec time difference between current and previous return value of GetMicrosecondCount() or

- you might also want to have a look at GetTickCount() if milliseconds are sufficient (compared to microseconds)

[edit: okay....  @lippmaje was faster with the answer ;-) ]
 

@Enrique Dangeroux @lippmaje@Chris70

You are all right, but these are all workaround only.

On some circumstances, you may need to have real local time milliseconds synchronized with the server, and this is not possible.

 
lippmaje:
In MQL 5, MqlTick contains the tick time in milliseconds. datetime is Unix style, number of seconds since 1970.
Nice ! Thanks.
 
Chris70:

probably also useful in in this context is the current tick time with millisec precision:

so you could either use

- the msc time difference between current and precious tick.time_msc or

- the microsec time difference between current and previous return value of GetMicrosecondCount() or

- you might also want to have a look at GetTickCount() if milliseconds are sufficient (compared to microseconds)

[edit: okay....  @lippmaje was faster with the answer ;-) ]
Thank you.
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
Reason: