Time update in code

 

If call TimeCurrent() in start of OnTick() and in the end. Do TimeCurrent() changes if in interval of code running there will be tick?

Same question. but 1 additional thing. Between 2 TimeCurrents there RefreshRates().

void OnTick()
{
datetime time=TimeCurrent();

//new tick
//new tick+RefreshRates()

datetime time2=TimeCurrent();

//time==time2 ???????????
}

 

 

If call TimeLocal() in start of OnTimer() and in the end. Do TimeLocal() changes if in interval of code running will be 2 seconds(on timer is 1 second)?

Same question. but 1 additional thing. Between 2 TimeLocals there RefreshRates().

void OnTimer()
{
datetime time=TimeLocal();

//code running 2 seconds
//code running 2 seconds+RefreshRates()  

datetime time2=TimeCurrent();

//time==time2 ???????????
}
 

TimeCurrent is the last server response, so any tick on any instrument in the Market Watch can update it. I do not expect the RefreshRates has any effect.

TimeLocal is just the internal clock, it increments regardless of your code.

 

Wouldn't it be great if MQL4 has some kind of Print() command so that you can print values and inspect them yourself? 

Print - Common Functions - MQL4 Reference
Print - Common Functions - MQL4 Reference
  • docs.mql4.com
Print - Common Functions - MQL4 Reference
 

From the documentation

In the OnTick() handler, this function returns the time of the received handled tick. In other cases (for example, call in handlers OnInit(), OnDeinit(), OnTimer() and so on) this is the time of the last quote receipt for any symbol available in the "Market Watch" window, the time shown in the title of this window.


 
Keith Watford:

From the documentation

And? There is no answers.

 

Are you moderator? Why you do not delete flood? 

 
eevviill14:

And? There is no answers.

 

Are you moderator? Why you do not delete flood? 

You have been given your answer

In the OnTick() handler, this function returns the time of the received handled tick.


Yes, I am a Moderator. the word Moderator above my rating may have given you a clue. I see no evidence of flooding.
 

About TimeCurrent answers are founded.

 So new tick not changes TimeCurrent while code running, but RefreshRates do it.

 

 https://book.mql4.com/en/functions/datetime

Each tick is characterized with its own value of the server time that can be obtained using the TimeCurrent() function. During the execution, this value can only be changed as a result of the RefreshRates() function call. 

Date and Time - Standard Functions - MQL4 Tutorial
Date and Time - Standard Functions - MQL4 Tutorial
  • book.mql4.com
Date and Time - Standard Functions - MQL4 Tutorial
 

So I only need to know about TimeLocal(). 

 
eevviill14:

So I only need to know about TimeLocal(). 

Ovo Cz:

TimeLocal is just the internal clock, it increments regardless of your code.

 
eevviill14:

So I only need to know about TimeLocal(). 

It depends very much on what you need! TimeCurrent() allows you to order the prices it belongs to while TimelLocal() does not e.g. in case of a varying latency.
 

TimeLocal() updates each time while code running in OnTimer().

TimeCurrent() not  updates each time while code running in OnTick(). But after RefreshRates() new call of TimeCurrent() updates it.

Reason: