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

 
Alexey Kozitsyn:

Try it yourself. Start the indicator, turn off the terminal and turn it back on when the new hour arrives.

So if you get TimeCurrent

Returns the last known server time, the arrival time of the last quotation by one of the symbols selected in Market Watch.

This is correct.
 
Konstantin Nikitin:

So if you get TimeCurrent

Returns the last known server time, the arrival time of the last quote for one of the symbols selected in Market Watch.

That's right.

Can you tell me where in this code the TimeCurrent call is?

 
Alexey Kozitsyn:

Can you tell me where in this code the TimeCurrent call is made?

So the bar open time is still the same as it was before the terminal closed. A new bar is formed and the time is updated. What is the problem.

 
Konstantin Nikitin:

The time of bar opening is the same as the one we received before the terminal was closed. A new bar is formed and the time is updated. What is the problem.

That's the thing, the terminal switches off when the last hour bar on the chart has the hour 22:00. It is switched off at 22:45, for example. Turns on at 23:01 - time request for the last hour after the connection to the server has been established and after pre-request to OnInit() without any timers - it is still 22 hours. This is normal, do you think?

 

Check the candle time, not the calculation of the bars.
This is how it will update correctly (checked).

//--- Проверяем первый запуск индикатора
   if(prev_calculated<=0 || 
      _weekOpenTime!=iTime(_Symbol,PERIOD_W1,0)+SEC_PER_DAY ||
      _dayOpenTime!=iTime(_Symbol,PERIOD_D1,0) ||
      _hourOpenTime!=iTime(_Symbol,PERIOD_H1,0) )
     {
     
      _weekOpenTime= 0;
      _dayOpenTime = 0;
      _hourOpenTime= 0;
        
      //--- Проверяем, записано ли время открытия текущей недели
      if(!CheckCurrentWeekOpenTime())                              // Если время не записано
         return(0);                                                // Выходим
      //--- Проверяем, записано ли время открытия текущего дня
      if(!CheckCurrentDayOpenTime())                              // Если время не записано
         return(0);                                                // Выходим
      //--- Проверяем, записано ли время открытия текущего часа
      if(!CheckCurrentHourOpenTime())                              // Если время не записано
         return(0);                                                // Выходим
      //--- Устанавливаем флаг соединения с сервером для запуска таймера
      _isConnected=true;
      //---
      Print(__FUNCTION__,": Данные старших ТФ загружены!");
     }
 
As I understand it, the terminal, for the first time, gives the last data it has in the history, and then it is downloaded from the server.
 
Taras Slobodyanik:

Do not check the calculation of bars, but the candlestick time.
That's how it will update correctly (checked).

What kind of bar calculation are we talking about?

I will check your variant, but actually you just added one "idle" data request into OnCalculate() and that's all. And by logic, it will not even get to the "idle" request, because prev_calculated <= 0 will already be executed and the first run block will be executed.

Anyway, this is a crutch, there must not be such situations in the language. The connection is established, the function of data acquisition is checked for errors and correctness of the obtained data. But in the end what do we get? The data are still wrong.

Actually, if we want to be sure, we can simply request the current time in the inite and then request the current time in OnCalculate() and compare them until they are different. But that's the same crutch and shouldn't be the case.

 
Alexey Kozitsyn:

That's the thing, the terminal switches off when the last hour bar on the chart has the hour 22:00. It is switched off at 22:45, for example. Turns on at 23:01 - time request for the last hour after the connection to the server has been established and after pre-request to OnInit() without any timers - it is still 22 hours. Is this normal according to you?

The closing time of any last bar will be TimeCurrent (i.e. current). It seems to be what you need, judging by your question.

 
Taras Slobodyanik:
As I understand it, the terminal, for the first time, outputs the last data that it has in the history, and then the loading from the server happens.

Question! Why does it give out previous data after the connection to the server has already been established, there was a pre-query for data in OnInit(), a check for data loading in each of the CheckCurren...() functions. How many bloody checks do I need to make for everything to work properly...

 
Konstantin Nikitin:

The closing time of any last bar will be TimeCurrent (i.e. the current time). This seems to be what you need, judging by your question.

What closing time? I need an opening time...