Minute() returns wrong values - or am I wrong?

 

This little script:

void OnStart()
  {
//---
   int waitMinutes = 60,
       waitSec     = waitMinutes*60,
       waitMSec    = waitSec*1000;
   while ( Minute() < 48 ) { Sleep(30000);    Comment("Starting Eieruhr.. ",TimeToString(TimeCurrent(),TIME_SECONDS),"  m: ",(string)Minute()," => ",(string)(Minute() < 48)); }
   PlaySound("alert2.wav");
   while( !IsStopped() ) {
      Comment(TimeLocal()," next Uuuiii: ",datetime(TimeLocal()+waitSec));
      Sleep(waitMSec);
      PlaySound("alert2.wav");
   }
   Comment("Bye");
  }

produces this:




Actually it show this:


 

try to add

RefreshRates();
 

ok, that works, but I wouldn't expect it and neither for Minutes() nor for RefrehRates() this effect is mentioned :(

Sorry it is mentioned for Minute(): ".. last known server time by the moment of the program start (this value will not change within the time of the program execution)."

I never would have expected this.

Minute - Date and Time - MQL4 Reference
Minute - Date and Time - MQL4 Reference
  • docs.mql4.com
Minute - Date and Time - MQL4 Reference
 
In an infinite loop, the trading environment does not update, it is necessary to do it yourself.
 
Taras Slobodyanik:
In an infinite loop, the trading environment does not update, it is necessary to do it yourself.
?? TimeCurrent() is updated Minute() not. Intuitively I would expect that Minute() is treated similar to TimeCurrent().
 
While in a while loop i won't expect anything.
 
Carl Schreiber:
?? TimeCurrent() is updated Minute() not. Intuitively I would expect that Minute() is treated similar to TimeCurrent().

Yes indeed.
So this is a feature.

 
Carl Schreiber:
?? TimeCurrent() is updated Minute() not. Intuitively I would expect that Minute() is treated similar to TimeCurrent().

If researched, the update speed Minute() or TimeCurrent(), much depends on the internet connection speed between your Terminal and Server Broker.
When there is a delay, then Minute() or TimeCurrent() will jump to the time after delay.

 
Roberto Jacobs:

If researched, the update speed Minute() or TimeCurrent(), much depends on the internet connection speed between your Terminal and Server Broker.
When there is a delay, then Minute() or TimeCurrent() will jump to the time after delay.

??

Both Minute() and TimeCurrent() are called in the same code line:

Comment("Starting Eieruhr.. ",TimeToString(TimeCurrent(),TIME_SECONDS),"  m: ",(string)Minute()," => ",(string)(Minute() < 48)); 

There cannot be a difference between because of the internet speed!

But as this applies to Hour() and Seconds() as well (pls look in the editor's reference):

Seconds

Returns the amount of seconds elapsed from the beginning of the current minute of the last known server time by the moment of the program start.

int  Seconds();

Returned value

The amount of seconds elapsed from the beginning of the current minute of the last known server time by the moment of the program start (this value will not change within the time of the program execution).

Note

At the testing, the last known server time is modelled.

Example:

  if(Seconds()<=15)
    return(0);

I would give this functions the Golden Banana because

  1. real time seems to be treated differently:
        a) ... of the last known server time by the moment of the program start.
        b)
    At the testing, the last known server time is modelled.
  2. The name is totally misleading as not only me (I guess) assumes that a function with this name would return the seconds of the last known server time.
  3. Knowing the seconds the program was started is good for ...? I cannot imagine anything as we easily could save the complete start-time in OnInit() in seconds!
  4. Seconds() as a bit more ridiculous than Minutes() and Hour() - btw. in MT5 they don't exists.

Anyone with a different suggestion for the Golden Banana?

Reason: