How to calculate the time remaining to the Rollover (Swap) that starts at 22:00 GMT?

To add comments, please log in or register
Ziad El
122
Ziad El  

I need to calculate the time that is left for the Rollover starting at 22:00 GMT...

I can certainly find the current (local) time:

datetime TimeNow = TimeLocal();

But I have no clue how to proceed from here on...

The time difference between local time and GMT time is +3 hour (adding to GMT 3hours)

Please help

Mohamad Zulhairi Baba
15940
Mohamad Zulhairi Baba  
Ziad El:

I need to calculate the time that is left for the Rollover starting at 22:00 GMT...

I can certainly find the current (local) time:

But I have no clue how to proceed from here on...

The time difference between local time and GMT time is +3 hour (adding to GMT 3hours)

Please help

compare your broker time with GMT time.
countdown the difference.

Ziad El
122
Ziad El  

But how to make a subtraction with datetime  variables?

Could you provide me an example please?

Alain Verleyen
36058
Alain Verleyen  
Ziad El:

But how to make a subtraction with datetime  variables?

Could you provide me an example please?

You should do your home work.

Documentation on MQL5: Language Basics / Operations and Expressions
Documentation on MQL5: Language Basics / Operations and Expressions
  • www.mql5.com
Language Basics / Operations and Expressions - Reference on algorithmic/automated trading language for MetaTrader 5
Icham Aidibe
11287
Icham Aidibe  
Ziad El:

I need to calculate the time that is left for the Rollover starting at 22:00 GMT...

I can certainly find the current (local) time:

But I have no clue how to proceed from here on...

The time difference between local time and GMT time is +3 hour (adding to GMT 3hours)

Please help

In MQL5 : 

   MqlDateTime timerollover; // <--- time struct creation
   TimeGMT(timerollover); // <--- set it to current day, current yr, current mon etc ... at once
   timerollover.hour=22; timerollover.min=0; timerollover.sec = 0; // <---- override just hour, mn, seconds to set it to 22h
   printf("**** Remaining time until next rollover : %s",TimeToString(StructToTime(timerollover)-TimeGMT(),TIME_MINUTES|TIME_SECONDS)); // <--- substract after conversion

returns : 

2018.05.30 21:58:23.089 2018.01.02 13:24:30   **** Remaining time until next rollover : 08:35:30 // <--- it's a string

Check : 13h + 8h = 21h / 35m+24m = 59 m / 30s + 30s = 1m aka 21h + 59m + 1m = 22h.

Ziad El
122
Ziad El  

Thank you Mr. Aidibe

that was really helpful

To add comments, please log in or register