Synchronise Windows local time with the MT5 server - page 8

 

So what is to be believed (real)?

MqlTick cur_tick, ct_tick[];
   if(SymbolInfoTick(symb_si, cur_tick))
   {
     int result = CopyTicks(symb_si, ct_tick, COPY_TICKS_INFO, 0, 10);
     if(result>0)
     {
       Print("SymbolInfoTick symbol = ", symb_si, " time = ", cur_tick.time, ".", cur_tick.time_msc%1000, " ask = ", cur_tick.ask, " bid = ", cur_tick.bid, " flags = ", cur_tick.flags);
       for(int i = result-1; i >=0; i--)
       {
         Print("CopyTicks symbol = ", symb_si, " time ", string(i), " = ", ct_tick[i].time, ".", ct_tick[i].time_msc%1000, " ask = ", ct_tick[i].ask, " bid = ", ct_tick[i].bid, " flags = ", ct_tick[i].flags);
       }  
     }
   }
   Print("TICK_FLAG_BID = ", TICK_FLAG_BID);
   Print("TICK_FLAG_ASK = ", TICK_FLAG_ASK);
   Print("TICK_FLAG_LAST = ", TICK_FLAG_LAST);
   Print("TICK_FLAG_VOLUME = ", TICK_FLAG_VOLUME);
   Print("TICK_FLAG_BUY = ", TICK_FLAG_BUY);
   Print("TICK_FLAG_SELL = ", TICK_FLAG_SELL);

Result

2017.01.21 01:33:56.249 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick symbol = Si-3.17 time = 2017.01.20 23:59:56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 9 = 2017.01.20 23:54:35.904 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 8 = 2017.01.20 23:53:04.867 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 7 = 2017.01.20 23:51:55.889 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 6 = 2017.01.20 23:50:55.731 ask = 60492.0 bid = 60477.0 flags = 4
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 5 = 2017.01.20 23:49:58.818 ask = 60490.0 bid = 60477.0 flags = 4
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 4 = 2017.01.20 23:49:58.706 ask = 60489.0 bid = 60477.0 flags = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 3 = 2017.01.20 23:49:58.553 ask = 60489.0 bid = 60465.0 flags = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 2 = 2017.01.20 23:49:58.454 ask = 60489.0 bid = 60470.0 flags = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 1 = 2017.01.20 23:49:58.279 ask = 60489.0 bid = 60465.0 flags = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 0 = 2017.01.20 23:49:58.191 ask = 60489.0 bid = 60471.0 flags = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BID = 2
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_ASK = 4
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_LAST = 8
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_VOLUME = 16
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BUY = 32
2017.01.21 01:33:56.250 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_SELL = 64
2017.01.21 01:33:58.956 Time_sync_forts (ALRS-3.17,H1)  debugging terminated

Added

ChangingCOPY_TICKS_INFO to COPY_TICKS_ALL

MqlTick cur_tick, ct_tick[];
   if(SymbolInfoTick(symb_si, cur_tick))
   {
     int result = CopyTicks(symb_si, ct_tick, COPY_TICKS_ALL, 0, 10);
     if(result>0)
     {
       Print("SymbolInfoTick symbol = ", symb_si, " time = ", cur_tick.time, ".", cur_tick.time_msc%1000, " ask = ", cur_tick.ask, " bid = ", cur_tick.bid, " flags = ", cur_tick.flags);
       for(int i = result-1; i >=0; i--)
       {
         Print("CopyTicks symbol = ", symb_si, " time ", string(i), " = ", ct_tick[i].time, ".", ct_tick[i].time_msc%1000, " ask = ", ct_tick[i].ask, " bid = ", ct_tick[i].bid, " flags = ", ct_tick[i].flags);
       }  
     }
   }
   Print("TICK_FLAG_BID = ", TICK_FLAG_BID);
   Print("TICK_FLAG_ASK = ", TICK_FLAG_ASK);
   Print("TICK_FLAG_LAST = ", TICK_FLAG_LAST);
   Print("TICK_FLAG_VOLUME = ", TICK_FLAG_VOLUME);
   Print("TICK_FLAG_BUY = ", TICK_FLAG_BUY);
   Print("TICK_FLAG_SELL = ", TICK_FLAG_SELL);

Result

2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick symbol = Si-3.17 time = 2017.01.20 23:59:56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 9 = 2017.01.20 23:54:35.904 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 8 = 2017.01.20 23:53:04.867 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 7 = 2017.01.20 23:51:55.889 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 6 = 2017.01.20 23:50:55.731 ask = 60492.0 bid = 60477.0 flags = 4
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 5 = 2017.01.20 23:49:59.296 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 4 = 2017.01.20 23:49:59.59 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 3 = 2017.01.20 23:49:58.937 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 2 = 2017.01.20 23:49:58.934 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 1 = 2017.01.20 23:49:58.933 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 0 = 2017.01.20 23:49:58.933 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BID = 2
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_ASK = 4
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_LAST = 8
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_VOLUME = 16
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BUY = 32
2017.01.21 01:43:04.843 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_SELL = 64
2017.01.21 01:43:06.795 Time_sync_forts (ALRS-3.17,H1)  debugging terminated

Si-3.17 last = 60490

  • TICK_FLAG_BID - tick changed the price of the bid
  • TICK_FLAG_ASK - tick changed Ask price
  • TICK_FLAG_LAST - tick changed price of last deal
  • TICK_FLAG_VOLUME - Tick has changed volume
  • TICK_FLAG_BUY - Tick occurred as a result of a buy deal
  • TICK_FLAG_SELL - a tick occurred as a result of a sell deal

Maybe, for a better understanding, go for a beer?

 

I've had a beer, but I still don't get it.

   MqlTick cur_tick, ct_tick[];
   if(SymbolInfoTick(symb_si, cur_tick))
   {
     int result = CopyTicks(symb_si, ct_tick, COPY_TICKS_ALL, 0, 10);
     if(result>0)
     {
       Print("SymbolInfoTick symbol = ", symb_si, " time = ", cur_tick.time, ".", cur_tick.time_msc%1000, " ask = ", cur_tick.ask, " bid = ", cur_tick.bid, " flags = ", cur_tick.flags);
       if((cur_tick.flags & TICK_FLAG_BID) == TICK_FLAG_BID)
         Print("SymbolInfoTick change BID");
       if((cur_tick.flags & TICK_FLAG_ASK) == TICK_FLAG_ASK)
         Print("SymbolInfoTick change ASK");
         if((cur_tick.flags & TICK_FLAG_LAST) == TICK_FLAG_LAST)
         Print("SymbolInfoTick change LAST");
         if((cur_tick.flags & TICK_FLAG_VOLUME) == TICK_FLAG_VOLUME)
         Print("SymbolInfoTick change VOLUME");
         if((cur_tick.flags & TICK_FLAG_BUY) == TICK_FLAG_BUY)
         Print("SymbolInfoTick change BUY");
         if((cur_tick.flags & TICK_FLAG_SELL) == TICK_FLAG_SELL)
         Print("SymbolInfoTick change SELL");
       for(int i = result-1; i >=0; i--)
       {
         Print("CopyTicks symbol = ", symb_si, " time ", string(i), " = ", ct_tick[i].time, ".", ct_tick[i].time_msc%1000, " ask = ", ct_tick[i].ask, " bid = ", ct_tick[i].bid, " flags = ", ct_tick[i].flags);
         if((ct_tick[i].flags & TICK_FLAG_BID) == TICK_FLAG_BID)
         Print("CopyTicks change BID");
       if((ct_tick[i].flags & TICK_FLAG_ASK) == TICK_FLAG_ASK)
         Print("CopyTicks change ASK");
         if((ct_tick[i].flags & TICK_FLAG_LAST) == TICK_FLAG_LAST)
         Print("CopyTicks change LAST");
         if((ct_tick[i].flags & TICK_FLAG_VOLUME) == TICK_FLAG_VOLUME)
         Print("CopyTicks change VOLUME");
         if((ct_tick[i].flags & TICK_FLAG_BUY) == TICK_FLAG_BUY)
         Print("CopyTicks change BUY");
         if((ct_tick[i].flags & TICK_FLAG_SELL) == TICK_FLAG_SELL)
         Print("CopyTicks change SELL");
       }  
     }
   }
   Print("TICK_FLAG_BID = ", TICK_FLAG_BID);
   Print("TICK_FLAG_ASK = ", TICK_FLAG_ASK);
   Print("TICK_FLAG_LAST = ", TICK_FLAG_LAST);
   Print("TICK_FLAG_VOLUME = ", TICK_FLAG_VOLUME);
   Print("TICK_FLAG_BUY = ", TICK_FLAG_BUY);
   Print("TICK_FLAG_SELL = ", TICK_FLAG_SELL);

Result

2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick symbol = Si-3.17 time = 2017.01.20 23:59:56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 9 = 2017.01.20 23:54:35.904 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 8 = 2017.01.20 23:53:04.867 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 7 = 2017.01.20 23:51:55.889 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 6 = 2017.01.20 23:50:55.731 ask = 60492.0 bid = 60477.0 flags = 4
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 5 = 2017.01.20 23:49:59.296 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BUY
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 4 = 2017.01.20 23:49:59.59 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BUY
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 3 = 2017.01.20 23:49:58.937 ask = 60490.0 bid = 60477.0 flags = 56
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BUY
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 2 = 2017.01.20 23:49:58.934 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change SELL
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 1 = 2017.01.20 23:49:58.933 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change SELL
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 0 = 2017.01.20 23:49:58.933 ask = 60490.0 bid = 60477.0 flags = 88
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change SELL
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BID = 2
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_ASK = 4
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_LAST = 8
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_VOLUME = 16
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_BUY = 32
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  TICK_FLAG_SELL = 64
2017.01.21 02:41:19.989 Time_sync_forts (ALRS-3.17,H1)  debugging terminated

Where did the tick in2017.01.2023:59:56.0 come from?

It's not in the tick history:(

And where did the last 3 ticks in CopyTicks() (also non-trading time) come from ?

Did they withdraw the bids ? But then the volume should change, or price, as in this tick

CopyTicks symbol = Si-3.17 time6=2017.01.2023:50:55.731 ask =60492.0 bid =60477.0 flags =4

Maybe I should drink some vodka in grief?

 
Sergey Chalyshev:

Try what I've got:

Time fluctuates due to ping, server and terminal delays. But within -10; +10; milliseconds it works.

In the premarket the ticks come too.

I tried your Expert Advisor in the premarket - the difference is 47 sec.
 

I didn’t drink vodka, but sent a letter to the technical support of the exchange

Отправленные: 21.01 . 2017 19 : 14 : 36
По: help@moex.com
Копия:
Тема: Si- 3.17 (N879289N)


Добрый день!

Разбираемся с разработчиками MetaTrader 5 по поводу
некоректного отображения времени в заявках.
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   SymbolInfoTick symbol = Si- 3.17 time = 2017.01 . 20 23 : 59 : 56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   SymbolInfoTick change BID
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   SymbolInfoTick change ASK
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   SymbolInfoTick change LAST
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   SymbolInfoTick change VOLUME
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks symbol = Si- 3.17 time 9 = 2017.01 . 20 23 : 54 : 35.904 ask = 60492.0 bid = 60477.0 flags = 6
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change BID
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change ASK
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks symbol = Si- 3.17 time 8 = 2017.01 . 20 23 : 53 : 04.867 ask = 60492.0 bid = 60477.0 flags = 6
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change BID
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change ASK
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks symbol = Si- 3.17 time 7 = 2017.01 . 20 23 : 51 : 55.889 ask = 60492.0 bid = 60477.0 flags = 6
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change BID
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change ASK

Не могли бы Вы прислать маленькую выдержку из ордерслог
по инструменту Si- 317 за последнюю минуту ( 23 : 49 : 00.000 - 23 : 50 : 00.000 ) торгов 20.01 . 2017 г.

Got an answer

Запрашиваемая информация во вложенном файле.

С уважением,
Михаил Ващук
Техническая поддержка ПАО Московская Биржа
+ 7 ( 495 ) 733 - 95 - 07 | help@moex.com

Full log in the basement

The last transaction was

61121621267      61121621267      0        24657041869      5205      795262    1        160      1693722330        4097      4097      60490.00000      2017 - 01 - 20 23 : 49 : 59.297 2        2        60490.00000


2017-01-20 23:49:59.297

What corresponds to a deal in CopyTicks()

2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks symbol = Si- 3.17 time 5 = 2017.01 . 20 23 : 49 : 59.296 ask = 60490.0 bid = 60477.0 flags = 56
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change LAST
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change VOLUME
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change BUY

This, already outside the "outside" of the exchange time ( 2017.01 . 20   23 : 50 : 55.731 )

2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks symbol = Si- 3.17 time 6 = 2017.01 . 20 23 : 50 : 55.731 ask = 60492.0 bid = 60477.0 flags = 4
2017.01 . 21 02 : 41 : 17.976 Time_sync_forts (ALRS- 3.17 ,H1)   CopyTicks change ASK

And where is the correspondence to this (exchange log)

61121621327      61121621327      0        24657043258      5205      795262    200      0        0        2102273 2102273 60500.00000      2017 - 01 - 20 23 : 49 : 59.457 2        0        0.00000
61121621392      61121621392      0        24657043455      5205      795262    200      200      0        5121      5121      60505.00000      2017 - 01 - 20 23 : 49 : 59.617 2        1        0.00000
61121621501      61121621501      0        24657043464      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621502      61121621502      0        24657043464      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621504      61121621504      0        24657043465      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621505      61121621505      0        24657043465      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621507      61121621507      0        24657043466      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621508      61121621508      0        24657043466      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621510      61121621510      0        24657043467      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621511      61121621511      0        24657043467      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621513      61121621513      0        24657043468      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621514      61121621514      0        24657043468      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621516      61121621516      0        24657043469      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621517      61121621517      0        24657043469      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621519      61121621519      0        24657043470      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621520      61121621520      0        24657043470      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621522      61121621522      0        24657043471      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        1        0.00000
61121621523      61121621523      0        24657043471      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 49 : 59.997 1        0        0.00000
61121621525      61121621525      0        24657043472      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621526      61121621526      0        24657043472      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621528      61121621528      0        24657043473      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621529      61121621529      0        24657043473      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621531      61121621531      0        24657043474      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621532      61121621532      0        24657043474      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621534      61121621534      0        24657043475      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621535      61121621535      0        24657043475      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621537      61121621537      0        24657043476      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621538      61121621538      0        24657043476      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621540      61121621540      0        24657043477      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621541      61121621541      0        24657043477      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621543      61121621543      0        24657043478      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621544      61121621544      0        24657043478      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621546      61121621546      0        24657043479      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621547      61121621547      0        24657043479      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621549      61121621549      0        24657043480      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621550      61121621550      0        24657043480      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621552      61121621552      0        24657043481      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621553      61121621553      0        24657043481      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621555      61121621555      0        24657043482      5205      795262    1        1        0        1026      1026      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        1        0.00000
61121621556      61121621556      0        24657043482      5205      795262    1        0        0        4098      4098      58609.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621627      61121621627      0        24657043238      5205      795262    200      0        0        2102273 2102273 60450.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621635      61121621635      0        24657043455      5205      795262    200      0        0        2102273 2102273 60505.00000      2017 - 01 - 20 23 : 50 : 00.000 2        0        0.00000
61121621677      61121621677      0        24657043152      5205      795262    1000      0        0        2102273 2102273 60456.00000      2017 - 01 - 20 23 : 50 : 00.000 1        0        0.00000
61121621679      61121621679      0        24657043434      5205      795262    1000      0        0        2102273 2102273 60519.00000      2017 - 01 - 20 23 : 50 : 00.000 2        0        0.00000

Legend

replID  replRev replAct id_ord  sess_id isin_id amount  amount_rest     id_deal xstatus status  price   moment  dir     action  deal_price
Files:
 

Requesting

int result = CopyTicks(symb_si, ct_tick, COPY_TICKS_ALL, 0, 10);


That's all I was supposed to get:

61121621549     61121621549     0       24657043480     5205    795262  1       1       0       1026    1026    58609.00000     2017-01-20 23:50:00.000 1       1       0.00000
61121621550     61121621550     0       24657043480     5205    795262  1       0       0       4098    4098    58609.00000     2017-01-20 23:50:00.000 1       0       0.00000
61121621552     61121621552     0       24657043481     5205    795262  1       1       0       1026    1026    58609.00000     2017-01-20 23:50:00.000 1       1       0.00000
61121621553     61121621553     0       24657043481     5205    795262  1       0       0       4098    4098    58609.00000     2017-01-20 23:50:00.000 1       0       0.00000
61121621555     61121621555     0       24657043482     5205    795262  1       1       0       1026    1026    58609.00000     2017-01-20 23:50:00.000 1       1       0.00000
61121621556     61121621556     0       24657043482     5205    795262  1       0       0       4098    4098    58609.00000     2017-01-20 23:50:00.000 1       0       0.00000
61121621627     61121621627     0       24657043238     5205    795262  200     0       0       2102273 2102273 60450.00000     2017-01-20 23:50:00.000 1       0       0.00000
61121621635     61121621635     0       24657043455     5205    795262  200     0       0       2102273 2102273 60505.00000     2017-01-20 23:50:00.000 2       0       0.00000
61121621677     61121621677     0       24657043152     5205    795262  1000    0       0       2102273 2102273 60456.00000     2017-01-20 23:50:00.000 1       0       0.00000
61121621679     61121621679     0       24657043434     5205    795262  1000    0       0       2102273 2102273 60519.00000     2017-01-20 23:50:00.000 2       0       0.00000

For Sergei.

And this is beyond me at all.

2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick symbol = Si-3.17 time = 2017.01.20 23:59:56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change VOLUME
 

I checked again, just in case.

//+------------------------------------------------------------------+
//|                                                    TestTicks.mq5 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print("Test start.");
   MqlTick post_ticks[];
   string symbol = "Si-3.17";
   ulong from = ulong(D'2017.01.20 23:49:59') * 1000;
   int result=CopyTicks(symbol, post_ticks, COPY_TICKS_ALL, from, 20);
   if(result > 0)
   {
     for(int i = result - 1;i>=0;i--)
     {
       Print("Symbol = ", symbol, " Time = ", string(post_ticks[i].time) + "." + string(post_ticks[i].time_msc%1000), " flags = ", post_ticks[i].flags);
     }
   }
   Print("Test done.");
//---
   return(INIT_SUCCEEDED);
  }


But it's the same

2017.01.23 19:23:35.863 TestTicks (ALRS-3.17,H1)        Test start.
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 flags = 88
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 flags = 88
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 flags = 88
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:59:30.312 flags = 2
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:59:30.312 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:58:16.476 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:57:14.762 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:54:57.478 flags = 2
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:54:27.74 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:52:27.191 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:50:53.765 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:49:15.533 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:47:51.605 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:45:02.768 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:54:35.904 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:53:04.867 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:51:55.889 flags = 6
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:50:55.731 flags = 4
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:49:59.296 flags = 56
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:49:59.59 flags = 56
2017.01.23 19:23:35.957 TestTicks (ALRS-3.17,H1)        Test done.
 

Tomorrow I'm going to try this option, which synchronises the local

time with the server time when the first quote arrives at 10:00 a.m.

TimeTradeServer(s_time);

is used not to "twitch" GrtLocalTime() - external function.

//+------------------------------------------------------------------+
//|                                              Time_sync_forts.mq5 |
//|                                      Copyright 2017 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.03"
//---
struct _SYSTEMTIME
  {
   ushort            wYear;
   ushort            wMonth;
   ushort            wDayOfWeek;
   ushort            wDay;
   ushort            wHour;
   ushort            wMinute;
   ushort            wSecond;
   ushort            wMilliseconds;
  };

_SYSTEMTIME loc_time;

#import "kernel32.dll"
void GetLocalTime(_SYSTEMTIME &sys_time);
bool SetLocalTime(_SYSTEMTIME &sys_time);
#import
//---
bool     is_sync;
string   symb_rts;
string   symb_si;
string   symb_gold;
string   symb_br;
string   symb_gazr;
string   symb_sbrf;
//
input string           BrInstr   = "BR-2.17"; //Brent
input ENUM_DAY_OF_WEEK FirstDay  = SATURDAY;  //Первый выходной
input ENUM_DAY_OF_WEEK SecondDay = SUNDAY;    //Второй выходной
//+------------------------------------------------------------------+
//| Expert set second symbol function                                |
//+------------------------------------------------------------------+
string SetSecSymbol(const string a_symbol,const string prefix)
  {
   int str_tire=0;
   ushort let_symbol;
   int str_size=StringLen(a_symbol);

   for(int i=0; i<str_size; i++)
     {
      let_symbol=StringGetCharacter(a_symbol,i);

      if(let_symbol=='-')
        {
         str_tire=i;
         break;
        }
     }
   if(str_tire>0)
     {
      return(prefix + StringSubstr(a_symbol, str_tire, str_size - str_tire));
     }
   return("");
  }
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   is_sync=true;
   MarketBookAdd(Symbol());
//---  
   symb_rts=SetSecSymbol(Symbol(),"RTS");
   if(!SymbolSelect(symb_rts,true))
     {
      MessageBox(symb_rts+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_rts);
//---  
   symb_si=SetSecSymbol(Symbol(),"Si");
   if(!SymbolSelect(symb_si,true))
     {
      MessageBox(symb_si+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_si);
//---
   symb_gold=SetSecSymbol(Symbol(),"GOLD");
   if(!SymbolSelect(symb_gold,true))
     {
      MessageBox(symb_gold+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_gold);
//---
   symb_gazr=SetSecSymbol(Symbol(),"GAZR");
   if(!SymbolSelect(symb_gazr,true))
     {
      MessageBox(symb_gazr+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_gazr);
//---
   symb_sbrf=SetSecSymbol(Symbol(),"SBRF");
   if(!SymbolSelect(symb_sbrf,true))
     {
      MessageBox(symb_sbrf+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_sbrf);
//---
   symb_br=BrInstr;
   if(!SymbolSelect(symb_br,true))
     {
      MessageBox(symb_br+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_br);

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   MarketBookRelease(Symbol());
   MarketBookRelease(symb_rts);
   MarketBookRelease(symb_br);
   MarketBookRelease(symb_si);
   MarketBookRelease(symb_gold);
   MarketBookRelease(symb_gazr);
   MarketBookRelease(symb_sbrf);
  }
//+------------------------------------------------------------------+
//| Expert Convert To Time function                                  |
//+------------------------------------------------------------------+
bool ConvertToTime(const long n_value,_SYSTEMTIME  &a_time)
  {
   a_time.wMilliseconds=ushort(n_value%1000);
   ulong new_time=ulong(double(n_value)/1000);
   MqlDateTime cur_time={0};
   TimeToStruct(datetime(new_time),cur_time);
   if(cur_time.year>0)
     {
      a_time.wDay=ushort(cur_time.day);
      a_time.wDayOfWeek=ushort(cur_time.day_of_week);
      a_time.wHour=ushort(cur_time.hour);
      a_time.wMinute= ushort(cur_time.min);
      a_time.wMonth = ushort(cur_time.mon);
      a_time.wSecond= ushort(cur_time.sec);
      a_time.wYear=ushort(cur_time.year);
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
//| Expert On book event function                                    |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
  {
   if(!is_sync)
     {
      loc_time.wYear=0;
      GetLocalTime(loc_time);
      if(loc_time.wYear>0)
        {
         if((int(loc_time.wDayOfWeek) == int(FirstDay)) ||
            (int(loc_time.wDayOfWeek) == int(SecondDay))) return;
         MqlTick curr_tick[1];
         if(CopyTicks(symbol,curr_tick,COPY_TICKS_INFO,0,1)==1)
           {
            MqlDateTime sv_time={0};
            TimeToStruct(curr_tick[0].time,sv_time);
            if(sv_time.year>0)
              {
               int st_time=int(10*3600); //10:00:00
               int end_time=int(10*3600+1);//10:00:01
               int cur_time= sv_time.hour * 3600 + sv_time.min * 60 + sv_time.sec;
               if((cur_time>=st_time) && (cur_time<=end_time))
                 {
                  long last_ping=long(NormalizeDouble((double(TerminalInfoInteger(TERMINAL_PING_LAST))/1000)/2,0));
                  long mls_time=long(curr_tick[0].time_msc%1000);
                  if((mls_time+last_ping)>999)
                    {
                     mls_time=long(curr_tick[0].time_msc)+last_ping;
                     if(!ConvertToTime(mls_time, loc_time)) return;
                    }
                  else
                    {
                     loc_time.wMinute = ushort(sv_time.min);
                     loc_time.wSecond = ushort(sv_time.sec);
                     loc_time.wMilliseconds=ushort(mls_time);
                    }
                  if(SetLocalTime(loc_time))
                    {
                     is_sync=true;
                     Print("Local time sync is done. Symbol = ",symbol," Sync min = ",loc_time.wMinute,
                           " Sync sec = ",loc_time.wSecond," Sync ms = ",loc_time.wMilliseconds);
                    }
                 }
              }
           }
        }
     }
   else
     {
      MqlDateTime s_time={0};
      TimeTradeServer(s_time);
      if(s_time.year>0) if(s_time.hour==9) is_sync=false;
     }
  }
//+------------------------------------------------------------------+
 
prostotrader:

I did not drink vodka, but sent a letter to exchange technical support

Отправленные: 21.01.2017 19:14:36
По: help@moex.com
Копия:
Тема: Si-3.17 (N879289N)


Добрый день!

Разбираемся с разработчиками MetaTrader 5 по поводу
некоректного отображения времени в заявках.
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick symbol = Si-3.17 time = 2017.01.20 23:59:56.0 ask = 60492.0 bid = 60477.0 flags = 30
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change LAST
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  SymbolInfoTick change VOLUME
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 9 = 2017.01.20 23:54:35.904 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 8 = 2017.01.20 23:53:04.867 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks symbol = Si-3.17 time 7 = 2017.01.20 23:51:55.889 ask = 60492.0 bid = 60477.0 flags = 6
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change BID
2017.01.21 02:41:17.976 Time_sync_forts (ALRS-3.17,H1)  CopyTicks change ASK

Не могли бы Вы прислать маленькую выдержку из ордерслог
по инструменту Si-317 за последнюю минуту (23:49:00.000 - 23:50:00.000) торгов 20.01.2017 г.


So far, not very clear, it was necessary to ask for exchange log not for the last minute(23:49:00.000-23:50:00.000) of trading, but just for the last minute, because then goes withdrawal orders. And in the script it is desirable to output the Last price too.

 
Sergey Chalyshev:

It's not very clear yet, you should have asked for the exchange log not for the last minute(23:49:00.000-23:50:00.000) of trading, but just for the last minute, because further is the withdrawal of bids. And in the script it is desirable to output the Last price too.

It makes 1000% sense to me!

Added by

The server is probably working correctly until 23:49:59 and then...

Added

from last

2017.01.23 20:56:21.442 TestTicks (ALRS-3.17,H1)        Test start.
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 last =60460.0 flags = 88
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 last =60464.0 flags = 88
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 10:00:00.0 last =60465.0 flags = 88
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:59:30.312 last =0.0 flags = 2
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:59:30.312 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:58:16.476 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:57:14.762 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:54:57.478 last =0.0 flags = 2
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:54:27.74 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:52:27.191 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:50:53.765 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:49:15.533 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:47:51.605 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.23 09:45:02.768 last =0.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:54:35.904 last =60490.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:53:04.867 last =60490.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:51:55.889 last =60490.0 flags = 6
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:50:55.731 last =60490.0 flags = 4
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:49:59.296 last =60490.0 flags = 56
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Symbol = Si-3.17 Time = 2017.01.20 23:49:59.59 last =60490.0 flags = 56
2017.01.23 20:56:22.540 TestTicks (ALRS-3.17,H1)        Test done.
 

and in general, if you compare the log of the exchange with the log of CopyTicks () during working hours, then there are huge differences

20 lines from the exchange log

replID  replRev replAct id_ord  sess_id isin_id amount  amount_rest     id_deal xstatus status  price   moment  dir     action  deal_price
61121596561      61121596561      0        24657039482      5205      795262    5        5        0        5121      5121      60498.00000      2017 - 01 - 20 23 : 49 : 00.017 2        1        0.00000
61121596564      61121596564      0        24657039483      5205      795262    2        2        0        5121      5121      60497.00000      2017 - 01 - 20 23 : 49 : 00.020 1        1        0.00000
61121596784      61121596784      0        24653666035      5205      795262    1        0        0        2102273 2102273 60226.00000      2017 - 01 - 20 23 : 49 : 00.060 1        0        0.00000
61121596860      61121596860      0        24653666013      5205      795262    1        0        0        2102273 2102273 60898.00000      2017 - 01 - 20 23 : 49 : 00.060 2        0        0.00000
61121596863      61121596863      0        24657039505      5205      795262    5        5        0        5121      5121      60499.00000      2017 - 01 - 20 23 : 49 : 00.060 2        1        0.00000
61121596874      61121596874      0        24657011636      5205      795262    100      0        0        2102273 2102273 60421.00000      2017 - 01 - 20 23 : 49 : 00.063 1        0        0.00000
61121596881      61121596881      0        24656457983      5205      795262    1        0        0        2102273 2102273 60386.00000      2017 - 01 - 20 23 : 49 : 00.063 1        0        0.00000
61121596944      61121596944      0        24656457986      5205      795262    1        0        0        2102273 2102273 60596.00000      2017 - 01 - 20 23 : 49 : 00.067 2        0        0.00000
61121597008      61121597008      0        24657039527      5205      795262    100      100      0        5121      5121      60397.00000      2017 - 01 - 20 23 : 49 : 00.073 1        1        0.00000
61121597151      61121597151      0        24657039552      5205      795262    3        3        0        1025      1025      60497.00000      2017 - 01 - 20 23 : 49 : 00.087 2        1        0.00000
61121597156      61121597156      0        24657039552      5205      795262    3        0        1693721366        1        1        60497.00000      2017 - 01 - 20 23 : 49 : 00.087 2        2        60497.00000
61121597157      61121597157      0        24657038660      5205      795262    3        60        1693721366        9223372034707296257      - 2147479551      60497.00000      2017 - 01 - 20 23 : 49 : 00.087 1        2        60497.00000
61121597221      61121597221      0        24657039555      5205      795262    22        22        0        1026      1026      60494.00000      2017 - 01 - 20 23 : 49 : 00.090 2        1        0.00000
61121597226      61121597226      0        24657039555      5205      795262    22        0        1693721376        9223372034707292162      - 2147483646      60494.00000      2017 - 01 - 20 23 : 49 : 00.090 2        2        60497.00000
61121597227      61121597227      0        24657038660      5205      795262    22        38        1693721376        9223372034707296257      - 2147479551      60497.00000      2017 - 01 - 20 23 : 49 : 00.090 1        2        60497.00000
61121597250      61121597250      0        24657039400      5205      795262    1000      0        0        2102273 2102273 60477.00000      2017 - 01 - 20 23 : 49 : 00.093 1        0        0.00000
61121597260      61121597260      0        24657039558      5205      795262    2        2        0        1025      1025      60497.00000      2017 - 01 - 20 23 : 49 : 00.093 2        1        0.00000
61121597265      61121597265      0        24657039558      5205      795262    2        0        1693721380        1        1        60497.00000      2017 - 01 - 20 23 : 49 : 00.093 2        2        60497.00000
61121597266      61121597266      0        24657038660      5205      795262    2        36        1693721380        9223372034707296257      - 2147479551      60497.00000      2017 - 01 - 20 23 : 49 : 00.093 1        2        60497.00000
61121597291      61121597291      0        24657034498      5205      795262    1        0        0        2102273 2102273 60467.00000      2017 - 01 - 20 23 : 49 : 00.097 1        0        0.00000

The code

//+------------------------------------------------------------------+
//|                                                    TestTicks.mq5 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
   Print ( "New test start." );
   MqlTick post_ticks[];
   string symbol = "Si-3.17" ;
   ulong from = ulong ( D'2017.01.20 23:49:00' ) * 1000 ;
   int result= CopyTicks (symbol, post_ticks, COPY_TICKS_ALL , from, 2000 );
   if (result > 0 )
   {
     Print ( "Total " , result, " ticks." );
     for ( int i = 0 ;i< result;i++)
     {
       Print ( "Symbol = " , symbol, " Time = " , string (post_ticks[i].time) + "." + string (post_ticks[i].time_msc% 1000 ), " last =" , post_ticks[i].last, " flags = " , post_ticks[i].flags);
     }
   }
   Print ( "Test done." );
//---
   return ( INIT_SUCCEEDED );
  }

N lines from the CopyTicks() log

2017.01 . 23 22 : 59 : 13.657 TestTicks (ALRS- 3.17 ,H1) New test start.

2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)        Total 2000 ticks.
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.88 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.90 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.94 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.109 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.109 last = 60497.0 flags = 2
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.114 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.114 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.114 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.114 last = 60497.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.147 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.502 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.529 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.581 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.624 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 00.669 last = 60498.0 flags = 56
2017.01 . 23 22 : 59 : 13.747 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.24 last = 60498.0 flags = 56
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.110 last = 60496.0 flags = 88
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.110 last = 60496.0 flags = 6
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.113 last = 60496.0 flags = 4
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.113 last = 60496.0 flags = 56
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.697 last = 60498.0 flags = 56
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.697 last = 60498.0 flags = 56
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 01.700 last = 60498.0 flags = 2
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 02.675 last = 60498.0 flags = 6
2017.01 . 23 22 : 59 : 13.748 TestTicks (ALRS- 3.17 ,H1)         Symbol = Si- 3.17 Time = 2017.01 . 20 23 : 49 : 02.675 last = 60496.0 flags = 88

Where did those ticks go?

61121596561      61121596561      0        24657039482      5205      795262    5        5        0        5121      5121      60498.00000      2017 - 01 - 20 23 : 49 : 00.017 2        1        0.00000
61121596564      61121596564      0        24657039483      5205      795262    2        2        0        5121      5121      60497.00000      2017 - 01 - 20 23 : 49 : 00.020 1        1        0.00000
61121596784      61121596784      0        24653666035      5205      795262    1        0        0        2102273 2102273 60226.00000      2017 - 01 - 20 23 : 49 : 00.060 1        0        0.00000
61121596860      61121596860      0        24653666013      5205      795262    1        0        0        2102273 2102273 60898.00000      2017 - 01 - 20 23 : 49 : 00.060 2        0        0.00000
61121596863      61121596863      0        24657039505      5205      795262    5        5        0        5121      5121      60499.00000      2017 - 01 - 20 23 : 49 : 00.060 2        1        0.00000
61121596874      61121596874      0        24657011636      5205      795262    100      0        0        2102273 2102273 60421.00000      2017 - 01 - 20 23 : 49 : 00.063 1        0        0.00000
61121596881      61121596881      0        24656457983      5205      795262    1        0        0        2102273 2102273 60386.00000      2017 - 01 - 20 23 : 49 : 00.063 1        0        0.00000
61121596944      61121596944      0        24656457986      5205      795262    1        0        0        2102273 2102273 60596.00000      2017 - 01 - 20 23 : 49 : 00.067 2        0        0.00000
61121597008      61121597008      0        24657039527      5205      795262    100      100      0        5121      5121      60397.00000      2017 - 01 - 20 23 : 49 : 00.073 1        1        0.00000
61121597151      61121597151      0        24657039552      5205      795262    3        3        0        1025      1025      60497.00000      2017 - 01 - 20 23 : 49 : 00.087 2        1        0.00000
Reason: