afshin_j:
I want to be able to see how many milliseconds have passed since a particular position has been opened.
If I do
The returned datetime value does not appear to have millisecond precision, even though I can see the open time for that position down to milliseconds in Metatrader's Trade tab in the Toolbox!
If I do
The returned value is Position opening time in milliseconds since 01.01.1970, but then I can't find a way to get the current time in milliseconds since 01.01.1970, therefore I can't know how many milliseconds has passed since the position is opened.
Is this impossible to do, or am I missing something?
Thanks
long now = (long) TimeCurrent() * 1000; long postime = PositionGetInteger(POSITION_TIME_MSC); long elapsedmsc = now - postime;
Sardion Maranatha:
Thanks, but I don't think this has millisecond precision. TimeCurrent() does not have millisecond accuracy. So what you wrote cannot distinguish between 1 second 999 millisecond, and 1 second 1 millisecond. They are both considered as 1 second as far as TimeCurrent() is concerned, so multiplying by 1000 does not help. Am I right?
afshin_j:
Thanks, but I don't think this has millisecond precision. TimeCurrent() does not have millisecond accuracy. So what you wrote cannot distinguish between 1 second 999 millisecond, and 1 second 1 millisecond. They are both considered as 1 second as far as TimeCurrent() is concerned, so multiplying by 1000 does not help. Am I right?
you can use current tick time_msc then to be more precise
Thanks, but I don't think this has millisecond precision. TimeCurrent() does not have millisecond accuracy. So what you wrote cannot distinguish between 1 second 999 millisecond, and 1 second 1 millisecond. They are both considered as 1 second as far as TimeCurrent() is concerned, so multiplying by 1000 does not help. Am I right?
What I'm trying to say is that your solution increments elapsedmsc by 1000 every 1 second. It's not possible to know exactly how many milliseconds have passed in-between those seconds.
Sardion Maranatha:
you can use current tick time_msc then to be more precise
you can use current tick time_msc then to be more precise
Isn't that the time of the last tick in milliseconds, as opposed to the current time?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to be able to see how many milliseconds have passed since a particular position has been opened.
If I do
The returned datetime value does not appear to have millisecond precision, even though I can see the open time for that position down to milliseconds in Metatrader's Trade tab in the Toolbox!
If I do
The returned value is Position opening time in milliseconds since 01.01.1970, but then I can't find a way to get the current time in milliseconds since 01.01.1970, therefore I can't know how many milliseconds has passed since the position is opened.
Is this impossible to do, or am I missing something?
Thanks