I had a MQL4 strategy based on the ticks but unfortunately I needed the duration between two ticks.
I thought that GetTickCount() did the job, but I have just understood the GetTickCount relies on the computer time, so at each run of the same test in the same interval of course I don't get the same times...
So all my strategy is to throw away...
Would you see or indicate to me a trick to get the time between two ticks in Test mode ?
Thanks a lot in advance !!!!
[EDIT] I was thinking about working at seconds instead of tick time using the TimeCurrent() function that's obviously accurate, the algorithm would be as follows:
at OnTick() event:
wait until a TimeCurrent() second changes as a start,
if the "seconds" value of TimeCurrent() has changed, do my job related on the N seconds elapsed...
What do you think of that? Do you think this is a good way to get a sufficient accuracy (1 second)?
Second question: how can I get the "seconds" part of TimeCurrent() ?
If you insist, use the timer.
int seconds = TimeCurrent() % 60;
That makes perfectly sense, agree with that; I know exactly what to do now.
In the meantime I have based my strategy on TimeCurrent() function, checking whether more than 1 minute had elapsed since the last tick and in that case deduce the market were closed/the servers or internet connection were broken. I did not expect more than 1 minute between ticks in some cases as you mentioned, so I need to adjust (rewrite one part of) my code. Thanks a lot for this information.
Do you agree with the following condition: if more than 1h has elapsed since the previous tick => deduce the market was closed/other malfunction from servers or internet connection. I believe there's no way to have more than 1h?
Note: the timer function does not work in Test mode ;-)
static datetime lasttime=0;
return; // market was closed, or first tick on startup
Print("seconds elapsed since last tick: ",seconds);
This is the kind of code I have implemented (actually yours does not work, and do not see how it could, but I get the big picture, which was the same as mine).
I understand you validate the fact that "if elpasted time > 1h: deduce the market was closed" :-)
Thanks a lot for your help!
This is perfectly clear, and it has already been clear from the beginning, I have never said the opposite.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.