[SERVICE DESK] Error in getting the time of the senior TF in the timer! - page 4

 
Vitaly Gorbunov:
Well I wouldn't say it's a crutch. I'm expecting a stream of quotes from the server otherwise the history won't be updated. Another option is to take local time of computer and correct it for time zone, which can be calculated automatically and in the end wait for quotes update anyway. It's a bit crooked but I don't think Metakvotov will change anything in MT4. At the end of the day it's a server connection problem that has to be handled one way or another.

There. And you've realised that this is a problem! But, I think it should be fixed and/or the help should be supplemented with an algorithm for all cases.

The data retrieval function should not give out left-handed data without errors and warnings!

This is not my first topic (previous one was about MT5, I haven't got any clear answer about it) about synchronization and following hangs/errors.

 
Alexey Kozitsyn:

Yes, that seems to work. As an option, it can be used. Thank you! But I would still like the functions to work properly.

It will work only if there are no missing bars - and this cannot be guaranteed. Suppose, for example, there are no new quotes on the server for the current hour (and maybe for the previous hour, too). Accordingly, the last bar is a previous one.

 
Ihor Herasko:

There are two significant errors in your approach to verification:

  1. In the OnInit() of the indicator you cannot get correct data of any TF, even the current one. The OnInit() of the indicator at the start of the terminal is executed almost in an empty window (there may not even be the data that was at the time of terminal shutdown). Even the market environment is often still unavailable. The help contains a lot of warnings about what not to do in OnInit(). Therefore, there is not much to include in its code. Usually, this is a check of the values of the set parameters, binding of indicator buffers to arrays, and creation of classes, if such are used. Everything else has to be done in OnCalculate().
  2. All these checks can be done only after OnCalculate is called at least once.

Igor, have you reviewed the code? Where do I get something in OnInit()?

2. What checks? Where is it written that the indicator must use OnCalculate() at least once to work correctly?

 
Alexey Navoykov:

It will only work if there are no missed bars, which cannot be guaranteed. Suppose there are no new quotes on the server for the current hour (and maybe for the previous hour as well). Accordingly, the last bar is some previous bar.

This (as I said, crutch) solution is so far better than nothing. As I said (and proved), there is a bug. The sooner the developers fix it, the better.

 
So it does not give out false data, it gives out the last data received and the error will not occur until the terminal starts to receive the quote stream. In your case, you are trying to get data before the quotes are received, so the programmer has to handle such exceptional situations himself. As well as any connection failures. What is the problem with MT5?
 
Alexey Navoykov:

It will only work if there are no missed bars, which cannot be guaranteed. Suppose there are no new quotes on the server for the current hour (and maybe for the previous hour as well). Therefore, the last bar is a previous bar.

The method with iBarShift allows identifying history gaps but it needs to be checked at certain intervals. I have written for myself a procedure that deals with it, and after that I have forgotten about gaps in MTF programs.
 
Vitaly Gorbunov:
So it doesn't give out any left data, it gives out the last data received and the error won't occur until the terminal starts to receive the quote stream. In your case, you are trying to receive data before the quotes start. As well as any connection failure. What is the problem with MT5?

Oh, man... We're already past that point. See your own log:

2018.09.21 15:02:42.910 Custom indicator test XAUUSD,H1: removed
2018.09.21 15:15:27.985 test XAUUSD,H1: initialized
2018.09.21 15:15:29.520 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.552 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.589 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.605 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.636 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.667 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.705 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.736 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.768 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.805 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.837 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.868 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.906 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.937 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:29.969 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.006 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.038 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.069 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.106 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.138 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:30.169 test XAUUSD,H1: OnTimer: Связь отсутствует!
2018.09.21 15:15:31.880 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #4066
2018.09.21 15:15:31.900 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:31.940 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:31.990 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:32.010 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:32.074 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:32.100 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:32.120 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0
2018.09.21 15:15:32.174 test XAUUSD,H1: test.mq4: Данные истории по последнему часу отсутствуют! Ошибка #0

Sequence. First we check the connection. Once the connection is established, we get the time. Explain to me, please, why the hell is error 4066 returned first and then it's not returned!? What has changed in 20ms since the last call?

 
Vitaly Gorbunov:
What's the problem with MT5 there very interesting to read?

https://www.mql5.com/ru/forum/219829

Клинч в индикаторах mql5.
Клинч в индикаторах mql5.
  • 2017.11.15
  • www.mql5.com
Недавно столкнулся с одной крайне неприятной проблемой...
 
Alexey Kozitsyn:

This (as I said, crutch) solution is so far better than nothing. As I said (and proved), there is a bug. The sooner the developers fix it, the better.

Well, if we talk about the best crutch, we should check not only the current hour, but all previous hours since the last known bar. Otherwise, you will get stuck on this check, if there are no quotes for the current hour.
 
Alexey Kozitsyn:

Oh, man... We're already past that point. See your own log:

Sequence. First we check the connection. Once the connection is established, we get the time. Explain to me, please, why the hell is error 4066 returned first and then it's not returned!? What has changed in 20ms since the last call?

The data is loaded error 4066 then it is a bug metakvotovtsev most likely received data is processed for this situation an error is not invented. Up to that point, everything makes sense.