Strange - Time[0] hasn't the actual Time

To add comments, please log in or register
sunshineh
1328
sunshineh  

Hi,

I have writen an Expert Advisor with the following code lines:

Print("Minute: ", TimeToStr(Time[0]), " LastMinuteTime: ", TimeToStr(lastMinuteTime));
                        if(lastMinuteTime != Time[0])
                        {
Print("**");
                           WriteMinute();
                           WriteMinute_Contract();
                           lastMinuteTime = Time[0];
                        }

I put this EA on the EURUSD M1 Chart and geht every tick the following lines:

2011.07.19 03:59:23 EA_Test EURUSD,M1: Minute: 2011.07.19 03:53 LastMinuteTime: 2011.07.19 03:53

WHY?

William Roeder
22734
William Roeder  
Why not? once lastMinuteTime is set to Time[0] the two will print equal for every tick in that minute.
sunshineh
1328
sunshineh  
Time[0] has to change it's value every minute! At 03:59:23 it couldn't be 03:53
sunshineh
1328
sunshineh  

Also the function Minute() returns only once a time the right value, it is when I active the ea. After that, the value is always the same!

I put the function in the start() not in the init().

Simon Gniadkowski
17281
Simon Gniadkowski  
sunshineh:
Time[0] has to change it's value every minute! At 03:59:23 it couldn't be 03:53

This part of what you copied from the Experts tab is your local PC time: 2011.07.19 03:59:23 EA_Test EURUSD,M1: and shows the date and time the entry was added to the Experts tab and log.

This part is what your print statement generated and is based on server time: Minute: 2011.07.19 03:53 LastMinuteTime: 2011.07.19 03:53

Your PC's clock is around 6 minutes fast . . .

sunshineh
1328
sunshineh  

@RaptorUK, this was only an example line, at PC-time 8:30:00 I got also the same statement.


I see, that functions Time[0] and Minute() are in a while-loop. Is that the problem?? That I get the timeinfo only when I enter the start-function again??

Simon Gniadkowski
17281
Simon Gniadkowski  
sunshineh:

@RaptorUK, this was only an example line, at PC-time 8:30:00 I got also the same statement.


I see, that functions Time[0] and Minute() are in a while-loop. Is that the problem?? That I get the timeinfo only when I enter the start-function again??

Can you show your code please ? it's hard to give any helpful advice without knowing what you have coded . ..
William Roeder
22734
William Roeder  
  1. sunshineh:
    Time[0] has to change it's value every minute! At 03:59:23 it couldn't be 03:53
    3:59 is your machine's local time, not related to the broker's.
  2. I see, that functions Time[0] and Minute() are in a while-loop. Is that the problem??
    It is if you are not calling RefreshRates. Nothing is going to change until you do or you exit start and wait for the next tick.
To add comments, please log in or register