TimeTradeServer analogue for MT4

 

Interested in solving this function on MT4

TimeTradeServer

Документация по MQL5: Дата и время / TimeTradeServer
Документация по MQL5: Дата и время / TimeTradeServer
  • www.mql5.com
Возвращает расчетное текущее время торгового сервера. В отличие от функции TimeCurrent(), расчет значения времени производится в клиентском терминале и зависит от настроек времени на компьютере пользователя. Существует 2 варианта функции.
 
Why?
 
Alexandr Gavrilin:

Interested in solving this function on MT4

TimeTradeServer

UseTimeCurrent()

 
GetTickCount at the beginning of each OnTick with remembered tick time. And in other On-functions you add the time difference to the remembered time via GetTickCount.
 
fxsaber:
The GetTickCount function in the beginning of each OnTick with saving of the tick time. And in other On-functions you add the time difference to the remembered time via GetTickCount.

If there are ticks, there is no question. What if the first run is on a weekend?

GetTickCount is not needed at all. Using the first tick, calculate the difference between TimeCurent() and TimeLocal() in hours. Then TimeLocal() should be recalculated with this correction.

 
Dmitry Fedoseev:

If there are ticks, there is no question. What if the first run is on a weekend?

GetTickCount is not needed at all. Using the first tick, calculate the difference between TimeCurent() and TimeLocal() in hours. Then TimeLocal() should be recalculated with this correction.

Sometimes it needs more accuracy.

 
fxsaber:

Sometimes you need to be more precise.

Server time is not the time of the quote, it only differs by hours, the speed of data delivery cannot affect it in any way. It is the quote that has the time of its appearance and the lag due to the time it takes to transmit it.

The most interesting thing, as always, is ignored - how to make it work when it first runs at the weekend.

 
Dmitry Fedoseev:

how to make it work when it first starts at the weekend.

By TimeLocal.

 
fxsaber:

By TimeLocal.

paññata

 
fxsaber:

On TimeLocal.

Please expand the thought a little bit. We started on Saturday. We have TimeCurrent() - Friday 23:59:59. What's next?

 
Ihor Herasko:

Spread the idea around a bit, please. Started on Saturday. We have TimeCurrent() - Friday 23:59:59. What next?

You have to ask developers this question, it would be more correct. It is not enough to get server time on weekends by standard means.

Reason: