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

 
Taras Slobodyanik:

I do not see the problem. A new candle appears - we recalculate the last candle in the indicator/advisor.
There is more than one new candle - we do a complete recalculation of the indicator/advisor.
This is the same - a new candle appears.

One more thing - the required periods should be constantly "pulled" to update them.
If there is nobody working on the symbol-period (quotes are not checked, the indicator is not running), then it "falls asleep", because it is considered unneeded.

We're pulling, we're pulling. We make a request, get an error, get out. But here, you see, another "peculiarity" comes out - the error does not reset after resetting. If it did, there would be no problem. But returning incorrect data is the problem. And I can see it very clearly.

The whole system of error checking goes down the drain on this example.

 

How does the terminal know that the latest data is out of date?
Because the history is there - it is there.
The request is sent to the broker... as soon as possible.

A new bar appears - the data is updated.

 
Taras Slobodyanik:

How does the terminal know that the latest data is out of date?
After all, there is a history - there is.
Request to the broker is sent... As soon as it is so.

A new bar appears - the data is updated.

Communication with the server is established. When requesting senior TF data, if data is not ready - error or return 0. If data is ready - return ONLY actual data. That's all. If data is not ready for a long time - let it return error or 0.

 
Taras Slobodyanik:

You didn't answer your question about the terminal version, by the way.

 
Alexey Kozitsyn:

By the way, you didn't answer the question about the terminal version.

What does the terminal version have to do with it at all? New data, it's there or it's not. And no version will save them if they didn't come from the server.
The indicator simply starts before the new data arrives. Alternatively, move checks to OnCalculate, which is triggered when new tick is received.

 
Konstantin Nikitin:

Alternatively, move the checks to OnCalculate, which is triggered when a new tick is received.

it has been suggested several times, and so has the admin

in the indicatorOnCalculate() will be started at indicator start, but the second time OnCalculate() will be started at the tick receipt - here it is necessary to start timer and download new OHLC data

 
Igor Makanu:

he has been offered it several times, and so has the admin

the indicator will start OnCalculate() at indicator start, but second time OnCalculate() will be started at tick receipt - here you need to enable the timer and download new OHLC data

Have a look at my last published code. It's not about timer, everything has been moved to OnCalculate() already. Still does not work when terminal starts.

 
//--- Проверяем связь с сервером
if(firstrun)
{
 firstrun=false;                // первый запуск индикатора
 return(0);
}   
if(!IsConnected())                              // Если не удалось установить связь с сервером
     {
      //--- Сбрасываем флаг соединения с сервером
      _isConnected=false;
      //--- Выходим
      return( 0 );
     }
I would also check GetTickCount() to give time for the terminal to load, generate graphs and establish communication with the server, you also need to track the restart of the terminal, I do not know how to track, but you need to give time
 
Alexey Kozitsyn:

Have a look at the last code I published. It's no longer about the timer, everything has already been moved to OnCalculate(). Still doesn't work when starting the terminal.

Well skip the first pass at startup

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   static bool res = false;
   if( !res )
     {
      res = true;
      return( rates_total );
     }
   /* работаем */
   return( rates_total );
  }
 
Konstantin Nikitin:

Well skip the first pass at start-up

Read point 1.