TimeTradeServer analogue for MT4 - page 4

 

It's a good point, you need to know server time on weekends. Because server time stops and always gives out Friday.
Need a way to identify, weekends for copiers without using dll

The TimeTradeServer works perfectly in MT5, add it to mt4 and that would solve the problems with time analysis at once.

 
Alexandr Gavrilin:

It's a good point here, you need to know the server time at the weekend. Because server time stops and always gives out Friday.
We need a way to identify the weekend for copiers without using dll

TimeTradeServer works perfectly in MT5, add it to mt4 and it would solve the problems with time analysis at once.

As the OrderSend() function runs into a "market is closed" error (there is some such thing), stop all trade attempts and wait for the price to change, which would mean that the market has opened.

 
Dmitry Fedoseev:

As the OrderSend() function comes across a "market closed" error (there's some such thing), we stop all trading attempts and wait for the price to change, which will mean that the market has opened.

and "as not encountered", the entire history is loaded with pending orders)

 
fxsaber:

Vitaly gave a link to this function. I don't remember what the idea is based on. But I must have checked it when I was writing. Give it a try.

The idea is based on finding last minute quotes for the most common symbol (in this case EURUSD) and sort of calculating server time offset from GMT. But there are so many "ifs" here that, unfortunately, it's not a solution to the problem.

Checked it on Alpari, it doesn't work:


 
Ihor Herasko:

Checked on Alpari, it doesn't work:

So will there be playback data?

 
fxsaber:

So there will be data to reproduce?

I gave a picture. Maybe you can't see it?

 
Taras Slobodyanik:

and "as I didn't come across", the whole story is littered with pauses)

Can you be more specific?

 
Ihor Herasko:

I gave a drawing.

How do you reproduce from a drawing?

 
Ihor Herasko:

The idea is based on finding the last minute quotes for the most common symbol (in this case EURUSD) and sort of calculating the server time offset from GMT from this. But there are so many "ifs" here that, unfortunately, it's not a solution to the problem.

Checked it on Alpari, it doesn't work:


you should not look for the last (23:59) minute on EURUSD, but the night on gold. Gold trades strictly on amsterdam, currencies on server time. From here find the GMT offset of the server
 

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql4, tips and tricks

Ivan Titov, 2019.08.12 16:19

Are you saying that if non forex characters have history available, then it will not work?

Also here is an example for forex on Alpari-Demo EURUSD,H1 in the tester:

For 2019.02.19 14:00:00 returns 2019.02.19 11:00:00

For 2019.06.19 14:00:00-returns 2019.06.19 11:00:00

Although in winter it should be GMT+2 and in summer GMT+3 (EET).

// Аналог по серверному времени - https://www.mql5.com/ru/docs/dateandtime/timegmtoffset
// Работает для FOREX-символов, когда M1-история доступна за ближайшую неделю
int TimeServerGMTOffset( const bool SummerTime = false )
{
  const datetime Sunday = GetTimeDayOfWeek();
  
  return(((int)MathRound((double)MathMin(Sunday - DAY - GetBarTime(Sunday), Sunday + DAY - GetBarTime(Sunday, true)) / HOUR) - SummerTime - 2) * HOUR);
}

Make such a change and it will work. Didn't do summer and winter definition, someone will do it.