A minute and a half difference between local time and fresh tick time. What to do. - page 5

 
pivomoe:
I know. What is your point ?

To what:

pivomoe:

In the market overview there are still columns "Volume" "Last trade " There is a suspicion that this function simply returns the .time of the last tick.

TheSymbolInfoInteger(_Symbol,SYMBOL_TIME) function returns just the time of the last tick. Because the change of a quote causes the appearance of a new informational tick.

You want to measure the time between the arrival of the last quote and the time of the last tick. In seconds, it seems to be always 0. Hence, the terminal returns everything promptly.

 
Alexey Kozitsyn:

To:

TheSymbolInfoInteger(_Symbol,SYMBOL_TIME) function returns just the time of the last tick. Because a change of a quote leads to a new informational tick.

You want to measure the time between the arrival of the last quote and the time of the last tick. In seconds, it seems to always be 0. Hence, the terminal returns everything promptly.

Once again what I see as the problem.

Given:

Local time and server time are more or less in sync i.e. the difference between .time_msc of new ticks and local time is a few seconds.

At 18:00:00 local time you're trying to get a new tick by SBER symbol with SymbolInfoTick, you get a tick with time 17:57:00

At 18:00:01 comp time we try to get a new tick with SymbolInfoTick, we get a tick with the time 17: 58:30

I don't think this can be called operational.

Now I've moved away from local computer time and use instead the maximal time of last tick among all symbols from market overview.

 
pivomoe:

Once again, what I see as the problem.

Given:

Local time and server time are more or less synchronized, i.e. difference between .time_msc of new tick and local time is few seconds.

At 18:00:00 local time you're trying to get a new tick by SBER symbol with SymbolInfoTick, you get a tick with time 17:57:00

At 18:00:01 comp time we try to get a new tick with SymbolInfoTick, we get a tick with the time 17: 58:30

I don't think this can be called operational.

Now I've moved away from local computer time and use instead the maximum time of last tick among all symbols from market overview.

Do you understand that you can set any computer time? You cannot use it. You have already been told that. This is the first thing.

Second, the maximum time of the last tick among all symbols from the market overview cannot be used. You want to find the lag of the time of the last tick of the SBER symbol (SymbolInfoTick) from the time of the last quote of the SBER symbol (SymbolInfoInteger). I.e. you have to do it roughly as I wrote (roughly because you need to use a tumbler for more accuracy, as you were advised).

Thirdly, this:

В 18:00:00 по времени компа  пытаемся получить новый тик по символу SBER с помощью SymbolInfoTick, нам отдают тик со временем 17:57:00

В 18:00:01 по времени компа опять пытаемся получить новый тик по символу SBER с помощью SymbolInfoTick, нам отдают тик со временем 17:58:30

Is claimed without evidence. If you consider your code as proof, see "second".

 
Alexey Kozitsyn:

Do you realise that you can set the computer time to anything? You cannot be bound to it. You've already been told that. First of all.


You cannot set it to any time if you are talking about milliseconds or even seconds. Talking about delays of minutes is quite possible. I'm not measuring the difference with it now, but with the maximum time .time_msc of the last tick for all symbols from the market overview.

Alexey Kozitsyn:

You want to find the lag of the time of the last tick of the SBER symbol (SymbolInfoTick) from the time of the last quote of the SBER symbol (SymbolInfoInteger).

I don't.

Alexey Kozitsyn:

Second, you can't use the maximum time of the last tick among all symbols from the market overview either.

Why ? I'm not comparing the time of the last tick ( by computer ) , I'm comparing the time_msc .

Alexey Kozitsyn:

I can't use your code without proof. If you consider your code as proof - see "second".

Usually developers ask for code to reproduce the problem. Here's a recently caught delay of 2 seconds.

14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)  РЕКОРДная  Разница между временем последенго тика по ВСЕМ символам Минус только, что полученный новый тик по символу 2057 милесекундa.
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Получен НОВЫЙ тик по символу                     GAZR-3.19 time_msc= 2019.03.20 14:53:11.638
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   ХОТЯ до этого был получeн тик                        RTS-3.19 time_msc 2019.03.20 14:53:13.695
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Локальное время получения нового тика по символу.                                   2019.03.20 14:53:10.277
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Предпоследние Локальное время попытки получить новый тик по символу    2019.03.20 14:53:10.259
AlexeyKozitsyn:

(roughly because you need to use a tumbler for greater accuracy, as you were advised).

I was advised to use OnBookEvent instead of OnTimer. I have implemented this. You can choose in settings where to receive ticks either OnTimer or OnBookEvent. It's even worse with OnBookEvent, it only catches 70% of new tick events.
 

pivomoe:

14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)  РЕКОРДная  Разница между временем последенго тика по ВСЕМ символам Минус только, что полученный новый тик по символу 2057 милесекундa.
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Получен НОВЫЙ тик по символу                     GAZR-3.19 time_msc= 2019.03.20 14:53:11.638
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   ХОТЯ до этого был получeн тик                        RTS-3.19 time_msc 2019.03.20 14:53:13.695
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Локальное время получения нового тика по символу.                                   2019.03.20 14:53:10.277
14:53:10.277    ProverkaAktyalnostiTikov (RTS-3.19,H1)   Предпоследние Локальное время попытки получить новый тик по символу    2019.03.20 14:53:10.259

From these lines alone, it seems clear what you want. You are interested in something like inter-symbol synchronisation. That is, the general relevance of the data on the instruments you want.

I can't help you with this at the moment, I wasn't involved in this question. Ask developers.

 
Alexey Kozitsyn:

From these lines alone, it seems clear what you want. You are interested in something like inter-symbol synchronisation. That is, the general relevance of the data on the instruments you want.

I can't help you with this at the moment, I wasn't involved in this question. Address to developers.

Alexey (didn't want to participate, but...).

Isn't it "relevance" (NEW_TICK) code from page 2 of this thread?

//+------------------------------------------------------------------+
//|                                                         Time.mq5 |
//|                                                   Copyright 2019 |
//|                                                                  |
//+------------------------------------------------------------------+
enum FRESH_TICK
{
  UNKNOWN_TICK,
  NEW_TICK,
  CUR_TICK
};
//
int is_book;
ulong last_tick_time; //Время последнего тика
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
  last_tick_time = 0;
  is_book = MarketBookAdd(Symbol());
  if(is_book == false) return(INIT_FAILED);
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  if(is_book == true) MarketBookRelease(Symbol()); 
}
//+------------------------------------------------------------------+
// Expert Book event function                                        |
//+------------------------------------------------------------------+  
void OnBookEvent(const string &symbol)
{
  if(symbol == Symbol())
  {
    MqlTick a_ticks[];
    int result = CopyTicks(symbol, a_ticks, COPY_TICKS_ALL, 0, 1);
    if(result > 0)
    {
      FRESH_TICK tick_state = CheckTickTime(a_ticks[0]);
      switch(tick_state)
      {
       case UNKNOWN_TICK:; //Тик не определен
       break;
       case NEW_TICK:;     //Торговое время, можно отсылать ордера;
       break;
       case CUR_TICK:;     //По усмотрению разработчика;
       break;
      }
    }  
  }
}
//+------------------------------------------------------------------+
//| Expert Check Market Time function                                |
//+------------------------------------------------------------------+
FRESH_TICK CheckTickTime(MqlTick &a_tick)
{
  MqlDateTime cur_time, tick_time;
  cur_time.year = 0;
  TimeTradeServer(cur_time); //Возвращает расчетное текущее время торгового сервера.
  if(cur_time.year > 0)
  {
    if(TimeToStruct(a_tick.time, tick_time) == true)
    {
      if(tick_time.day_of_year == cur_time.day_of_year)      //Проверка, что это сегодняшний тик
      {
        double t_msc = double(a_tick.time_msc - ulong(a_tick.time) * 1000)/1000;
        double tr_time = double(tick_time.hour * 3600 + tick_time.min * 60 + tick_time.sec) + t_msc;
        if(((tr_time >= 36000) && (tr_time < 50370)) ||   //10:00:00 - 13:59:30
           ((tr_time >= 50700) && (tr_time < 67470)) ||   //14:05:00 - 19:44:30 
           ((tr_time >= 68700) && (tr_time < 85770)))     //19:05:00 - 23:49:30
        {
          if(ulong(a_tick.time_msc) > last_tick_time)
          {
            last_tick_time = ulong(a_tick.time_msc);
            return(NEW_TICK);
          } else return(CUR_TICK);  
        }
      }
    }
  }   
  return(UNKNOWN_TICK);
} 

Added

With CUR_TICK, you can still make checks that it is the same tick as it was or

the new tick packet contains a tick that was not in the previous one.

 
prostotrader:

Alexey (didn't want to get involved, but...).

Isn't this the "relevance" (NEW_TICK) code from page 2 of this thread?

Apparently not. Since:

TimeTradeServer

Returns estimated current time of the trade server. UnlikeTimeCurrent(), the time value is calculated in the client terminal and depends on time settings on user's computer.

I.e. it depends on the computer time (it should not be so for the accuracy of measurement).

The good thing here, of course, is to checkpivomoe codefor correctness, and if there really is a bug - contact the developers.

 
prostotrader:

The check seems to need to be done via TimeGMTOffset. I'll sketch an example later.

 
Alexey Kozitsyn:

Apparently not. Because:


You look at the code carefully!

TimeTradeServer() is only taken to determine the day and that's it (this check is made "just in case")!

TimeTradeServer() may not be done at all!

Added by

I repeat

"With CUR_TICK, you can still check that it is the same tick as it was, or

the new tick packet contains a tick not passed in the previous packet, and the packet contains 1 tick("old")".

if(ulong(a_tick.time_msc) > last_tick_time)
{
  last_tick_time = ulong(a_tick.time_msc);
  return(NEW_TICK);
}
 else
{
   //Дополнительные проверки 
}
 
Alexey Kozitsyn:

The good thing here, of course, is to check thepivomoe codefor correctness and, if there is indeed a bug, contact the developers.

The bug appears either if there are dozens of characters in the market review or if there are several characters open in the review, but there are several dozens of tabs in the opera browser. I wrote to the developers via private message.

As I wrote earlier the problem is fixed with a big enough Sleep between calls, for 40 characters sleep(10) is enough. As the number of characters grows, more and more sleep is needed.