Tiki in tempo reale - pagina 12

 
Sergey Chalyshev:

Vorrei ricordare che OnTick riceve due thread indipendenti, informazione e commercio,COPY_TICKS_INFO e COPY_TICKS_ALL e subisce una pre-elaborazione .

Questi thread non sono sincronizzati tra loro, quindi se confrontate OnBookEvent con OnTick, dovreste prendereTICKS_INFO.

Per definizione, OnBookEvent dovrebbe essere più veloce, dato che non passa attraverso la pre-elaborazione.

I test non determinano in modo affidabile chi è più veloce, perché non conosciamo il tempo di giacenza di una zecca, a differenza delle zecche.

Anche se abbiamo chiesto molte volte agli sviluppatori di aggiungere il TEMPO DI STOCCAGGIO! ! !


p.s. oltre alla velocità, tumblr ha anche dei vantaggi rispetto a OnTick,

come già detto, non è possibile ottenere migliori prezzi Bid e Ask in OnTick,

eOnTick non ha dati da altri simboli, è inutile per gli Expert Advisors che analizzano diversi simboli.


ha cambiatoCOPY_TICKS_ALL inCOPY_TICKS_INFO

Risultato

2020.01.31 19:45:17.893 Ticks_test (GOLD-3.20,M1)       OnTick: 2020.01.31 19:45:11.360 Ask=1591.4 
2020.01.31 19:45:17.894 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:09.384 Ask=1591.3 
2020.01.31 19:45:17.973 Ticks_test (GOLD-3.20,M1)       OnTick: 2020.01.31 19:45:11.570 Ask=1591.1 
2020.01.31 19:45:17.973 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:09.384 Ask=1591.3 
2020.01.31 19:45:18.060 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:09.384 Ask=1591.3 
2020.01.31 19:45:18.077 Ticks_test (GOLD-3.20,M1)       OnTick: 2020.01.31 19:45:11.712 Bid=1591.4 
2020.01.31 19:45:18.077 Ticks_test (GOLD-3.20,M1)       OnTick: 2020.01.31 19:45:11.712 Bid=1591.4 
2020.01.31 19:45:18.078 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:09.384 Ask=1591.3 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:10.574 Ask=1591.2 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:10.742 Bid=1591.2 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:11.360 Ask=1591.4 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:11.570 Ask=1591.1 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:11.570 Ask=1591.4 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:11.712 Bid=1591.4 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:11.712 Bid=1591.4 
2020.01.31 19:45:18.356 Ticks_test (GOLD-3.20,M1)       OnBookEvent: 2020.01.31 19:45:12.14 Ask=1591.2 

Contrassegnato in giallo - stessa zecca!

Probabilmente c'è un'imprecisione nel codice dopo tutto...?
 

Per un secondo, sembrava che tu avessi il desiderio di sistemare le cose e che questo avrebbe aiutato a temperare il tuo orgoglio.
No, sembrava così e basta.

In generale, la questione è risolta, e chiunque può guardare i tuoi, quelli di fxsaber e i miei codici, e trarre conclusioni.
Con te smetto di dialogare, non arriva altro che un forte grido da parte tua, e alla ricezione delle informazioni il tuo cervello non funziona affatto.

Buona fortuna con FORTS.

 
Sergey Chalyshev:

Vorrei ricordare che OnTick riceve due thread indipendenti, informazione e commercio,COPY_TICKS_INFO e COPY_TICKS_ALL e subisce una pre-elaborazione .

Questi thread non sono sincronizzati tra loro, quindi se confrontate OnBookEvent con OnTick, dovreste prendereTICKS_INFO.

Sergei, noi usiamo le funzioni On semplicemente come punto di ingresso.

La domanda era quale punto di ingresso viene prima (pur dando la stessa informazione corretta sull'ultimo tick).

Esegui il mio EA e guarda il log. Il tempo dell'evento (preciso al ms) e il tempo dell'ultimo tick conosciuto (anch'esso con ms) sono emessi nel log.

Basta analizzare qualche spunta individuale per "chi è più precoce".


Sergey Chalyshev:

OnBookEvent dovrebbe essere più veloce per definizione, dato che non passa attraverso la pre-elaborazione.

Non credo che OnTick lo faccia. E i test lo confermano, non c'è nessun tipo di ritardo.


Sergey Chalyshev:

Come è già stato detto, è impossibile ottenere un miglior prezzo Bid e Ask in OnTick.

Possibilmente con CopyTicks.

Тики в реальном времени
Тики в реальном времени
  • 2020.01.31
  • www.mql5.com
Всем доброго времени суток. Появилась необходимость протестировать торговый алгоритм на реальных тиках брокера "Открытие...
 
Andrey Khatimlianskii:

Esegui il mio EA e guarda il log. Il tempo dell'evento (preciso al ms) e il tempo dell'ultimo tick conosciuto (anch'esso con ms) sono emessi nel log.

Basta analizzare qualche zecca individuale per "chi è più precoce".

Una situazione comune è quando OnBook arriva allo stesso tempo di OnTick o 1-2ms dopo. Ma ci sono anche dei ritardi:


 

Tra 5 ore:

2020.01.31 20:45:48.214 TestTicks (GOLD-3.20,M15)       63906 USE_BOOK events received
2020.01.31 20:45:52.782 TestTicks (GOLD-3.20,M15)       31199 USE_TICK events received

Il doppio degli eventi OnBook. Peccato che non tutti portino un carico utile (se sono necessari best bid/ask e flipper).

 
Andrey Khatimlianskii:

Sergey, stiamo usando le funzioni On semplicemente come punto di ingresso.

La domanda era quale punto di ingresso sarebbe arrivato per primo (pur dando le stesse informazioni corrette sull'ultimo tick).

Esegui il mio EA e guarda il log. Il tempo dell'evento (preciso al ms) e il tempo dell'ultimo tick conosciuto (anch'esso con ms) sono emessi nel log.

Basta analizzare qualche spunta individuale per "chi è più precoce".

Questo è il tuo modo di fare sbagliato. Forse l'evento tumblr è arrivato ma non è ancora entrato nella storia del tick. Dovresti confrontare i prezzi Bid Ask, non scavare nella storia dei tick.

Non credo che OnTick lo superi. E i test lo confermano, non c'è nessun ritardo.

Prima di entrare nella storia i tick vengono necessariamente elaborati e distribuiti a tutti i grafici, indicatori e Expert Advisors necessari. E tutto questo in MT5 è fatto in modo sequenziale (non in parallelo).

Forse con l'aiuto di CopyTicks.

No, conCopyTicks è anche impossibile ottenere il prezzo migliore, e cosa succede se è il tuo ordine che sta meglio.
 

Просто проанализируйте несколько отдельных тиков на предмет "кто раньше".

Ho un modo diverso di fare le cose:

tick vs libro

Le linee blu sono OnBook,

Quelli rossi sono OnCalculat = OnTick.

Se siete interessati, posso mostrarvi il codice

 
Sergey Chalyshev :

lo capisco diversamente:


le linee blu sono OnBook ,

rosso OnTick .

Se interessati posso mostrare il codice dell'indicatore

Niente Sereža!

Bisogna ammettere che OnBookEvent() e OnTick() sono tutti gli stessi tick (avevo un bug nel codice),

ma altre modifiche al DOM non si riflettono in alcun modo in OnTick()

Questo non è importante per i trader FOREX. (Citazione dal messaggio sopra: " Ci sono 2 volte più eventi OnBook. È un peccato che non tutti abbiano un carico utile (se hai bisogno di una migliore offerta/chiesta e un ultimo)" . )

Codice corretto:

 //+------------------------------------------------------------------+
//|                                                   Ticks_test.mq5 |
//|                                      Copyright 2019 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019 prostotrader"
#property link        "https://www.mql5.com"
#property version    "1.00"
//---
bool is_book;
MqlTick ticks[];
ulong last_time, mem_cnt, tot_cnt;
bool is_first;
int t_cnt, result;
enum ENUM_BOOK_OR_TICK
{
        USE_BOOK,       // Use OnBookEvent
        USE_TICK         // Use OnTick
};

input ENUM_BOOK_OR_TICK Mode = USE_BOOK;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
{
  tot_cnt = 0 ;
   if (Mode == USE_BOOK) is_book = MarketBookAdd ( Symbol ());
  result = CopyTicks ( Symbol (), ticks, COPY_TICKS_ALL , 0 , 1 );
   if (result > 0 )
  {
    last_time = ulong (ticks[ 0 ].time_msc); //запоминаем время последнего известного тика
    is_first = true ;
  }
   else
  {
    is_first = false ;
     Alert ( "No start time!" );
     return ( INIT_FAILED );
  } 
   ArraySetAsSeries (ticks, true );  
   return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+ 
//| возвращает строковое описание тика                               | 
//+------------------------------------------------------------------+ 
string GetTickDescription( MqlTick &tick) 
  { 
   string res = string (tick.time) + "." +   string (tick.time_msc% 1000 ); 
// 
   bool buy_tick = ((tick.flags& TICK_FLAG_BUY )== TICK_FLAG_BUY ); 
   bool sell_tick = ((tick.flags& TICK_FLAG_SELL )== TICK_FLAG_SELL ); 
   bool ask_tick = ((tick.flags& TICK_FLAG_ASK )== TICK_FLAG_ASK ); 
   bool bid_tick = ((tick.flags& TICK_FLAG_BID )== TICK_FLAG_BID ); 
   bool last_tick = ((tick.flags& TICK_FLAG_LAST )== TICK_FLAG_LAST ); 
   bool volume_tick = ((tick.flags& TICK_FLAG_VOLUME )== TICK_FLAG_VOLUME ); 
// 
   if ((buy_tick== true ) || (sell_tick == true )) 
   { 
     res = res + (buy_tick? StringFormat ( " Buy Tick: Last=%G Volume=%d " ,tick.last,tick.volume): "" ); 
     res = res + (sell_tick? StringFormat ( " Sell Tick: Last=%G Volume=%d " ,tick.last,tick.volume): "" ); 
     res = res + (ask_tick? StringFormat ( " Ask=%G " ,tick.ask): "" ); 
     res = res + (bid_tick? StringFormat ( " Bid=%G " ,tick.bid): "" ); 
   } 
   else 
   { 
     res = res + (ask_tick? StringFormat ( " Ask=%G " ,tick.ask): "" ); 
     res = res + (bid_tick? StringFormat ( " Bid=%G " ,tick.bid): "" ); 
     res = res + (last_tick? StringFormat ( " Last=%G " ,tick.last): "" ); 
     res = res + (volume_tick? StringFormat ( " Volume=%d " ,tick.volume): "" ); 
   } 
   return res; 
  } 
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
   if (Mode == USE_BOOK)
  {
     Print ( "USE_BOOK ticks received: " , tot_cnt);
     if (is_book == true ) MarketBookRelease ( Symbol ());
  }
   else
  {
     Print ( "USE_TICK ticks received: " , tot_cnt);
  }  
}
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
{
   if ( Mode != USE_BOOK || symbol != Symbol () ) return ;
  tot_cnt++;
   if (is_first == true )
  {
    result = CopyTicks ( Symbol (), ticks, COPY_TICKS_ALL , last_time, 0 ); //копируем все вновь пришедшие тики от последнего известного времени
     if (result > 0 )
    {
      t_cnt = 0 ;
       for ( int i= 0 ; i<result; i++)
      {
         if (ticks[i].time_msc == ticks[ 0 ].time_msc) t_cnt++;             //Считаем кол-во тиков с одинаковым временем
         Print ( __FUNCTION__ , ": " ,GetTickDescription(ticks[i]));
      }
      is_first = false ;
      last_time = ulong (ticks[ 0 ].time_msc);                             //Запоминаем время последнего тика
    } 
  }
   else
  {
    result = CopyTicks ( Symbol (), ticks, COPY_TICKS_ALL , last_time, 0 ); //забираем тики из последнего (посчитанного пакета тикив и считываем тики из нового пакета)
     if (result > 0 )
    {
       if (result > t_cnt)
      {
        mem_cnt = t_cnt;
        t_cnt = 0 ;
         for ( int i= 0 ; i<(result - int (mem_cnt)); i++)
        {
           if (ticks[i].time_msc == ticks[ 0 ].time_msc) t_cnt++;           //Считаем кол-во тиков с одинаковым временем
           Print ( __FUNCTION__ , ": " ,GetTickDescription(ticks[i]));
        } 
         if (last_time == ulong (ticks[ 0 ].time_msc))
        {
          t_cnt += int (mem_cnt);
        }
         else last_time = ulong (ticks[ 0 ].time_msc);
      }
       else
      {
         Print ( __FUNCTION__ , ": Pending order!" );                           //Изменения стакана (добавлен/удален отложенный ордер)
      }
    }
     else
    {
       Print ( __FUNCTION__ , ": Pending order!" );                             //Изменения стакана (добавлен/удален отложенный ордер)
    }
  }
}
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick ()
{
   if ( Mode != USE_TICK ) return ;
  tot_cnt++;
   if (is_first == true )
  {
    result = CopyTicks ( Symbol (), ticks, COPY_TICKS_ALL , last_time, 0 ); //копируем все вновь пришедшие тики от последнего известного времени
     if (result > 0 )
    {
      t_cnt = 0 ;
       for ( int i= 0 ; i<result; i++)
      {
         if (ticks[i].time_msc == ticks[ 0 ].time_msc) t_cnt++;             //Считаем кол-во тиков с одинаковым временем
         Print ( __FUNCTION__ , ": " ,GetTickDescription(ticks[i]));
      }
      is_first = false ;
      last_time = ulong (ticks[ 0 ].time_msc);                             //Запоминаем время последнего тика
    } 
  }
   else
  {
    result = CopyTicks ( Symbol (), ticks, COPY_TICKS_ALL , last_time, 0 ); //забираем тики из последнего (посчитанного пакета тикив и считываем тики из нового пакета)
     if (result > 0 )
    {
       if (result > t_cnt)
      {
        mem_cnt = t_cnt;
        t_cnt = 0 ;
         for ( int i= 0 ; i<(result - int (mem_cnt)); i++)
        {
           if (ticks[i].time_msc == ticks[ 0 ].time_msc) t_cnt++;           //Считаем кол-во тиков с одинаковым временем
           Print ( __FUNCTION__ , ": " ,GetTickDescription(ticks[i]));
        } 
         if (last_time == ulong (ticks[ 0 ].time_msc))
        {
          t_cnt += int (mem_cnt);
        }
         else last_time = ulong (ticks[ 0 ].time_msc);
      }
       else
      {
         Print ( __FUNCTION__ , ": Pending order!" );                           //Изменения стакана (добавлен/удален отложенный ордер)
      }
    }
     else
    {
       Print ( __FUNCTION__ , ": Pending order!" );                           //Изменения стакана (добавлен/удален отложенный ордер)
    }
  }
}
//+------------------------------------------------------------------+
Результат (фрагмент)
 2020.01 . 31 23 : 35 : 24.092 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 17.571 Bid= 1593.7 
2020.01 . 31 23 : 35 : 24.093 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 17.571 Bid= 1593.7 
2020.01 . 31 23 : 35 : 24.144 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 24.163 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 24.844 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 24.851 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 24.865 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.215 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.222 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.241 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.254 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.286 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.462 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.474 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.482 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.503 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.545 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 25.995 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.003 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.004 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.483 Buy Tick: Last= 1593.8 Volume= 1 
2020.01 . 31 23 : 35 : 26.011 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 19.484 Ask= 1593.9   Bid= 1593.8 
2020.01 . 31 23 : 35 : 26.012 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 19.484 Ask= 1593.9   Bid= 1593.8 
2020.01 . 31 23 : 35 : 26.061 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.075 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.142 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.155 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.162 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.191 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 26.213 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 27.293 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 27.345 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 27.936 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 27.943 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 28.166 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.657 Ask= 1594.1   Bid= 1593.9 
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.172 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.657 Ask= 1594.1   Bid= 1593.9 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.173 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.650 Buy Tick: Last= 1593.9 Volume= 1 
2020.01 . 31 23 : 35 : 28.191 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 21.661 Ask= 1594 
2020.01 . 31 23 : 35 : 28.192 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : 2020.01 . 31 23 : 35 : 21.661 Ask= 1594 
2020.01 . 31 23 : 35 : 28.255 Ticks_test (GOLD- 3.20 ,M1)       OnBookEvent : Pending order!
2020.01 . 31 23 : 35 : 29.516 Ticks_test (GOLD- 3.20 ,M1)       USE_BOOK ticks received: 153
2020.01 . 31 23 : 35 : 29.892 Ticks_test (GOLD- 3.20 ,M1)       OnTick : 2020.01 . 31 23 : 35 : 23.367 Ask= 1594.1 
2020.01 . 31 23 : 35 : 31.660 Ticks_test (GOLD- 3.20 ,M1)       USE_TICK ticks received: 27
 
prostotrader:

No Seryozh!

Devo ammettere che OnBookEvent() e OnTick() tutti i tick coincidono (ho avuto un errore nel codice),

ma altri cambiamenti nel bicchiere non si riflettono in OnTick()

Per le persone del FOREX non ha importanza.(Citazione prudente dal post sopra: "2 volte più eventi OnTick. Peccato che non tutti portino un carico utile (se hai bisogno di best bid/ask e flipper)".)

Codice corretto:

Risultato (snippet).

I ticchettii nella storia naturalmente corrisponderanno, ma nell'immagine sopra, si scopre che non tutti gli info-ticchettii arrivano alla storia o sono saltati in OnCalculat.

Non so se c'è un errore, cercherò di risolverlo lunedì.

 
prostotrader:


O forse per il tempo reale, invece di

MqlTick ticks[];
result = CopyTicks(Symbol(), ticks, COPY_TICKS_ALL, 0, 1);

utilizzare

MqlTick ticks[1];
bool success = SymbolInfoTick(_Symbol, ticks); //Возвращает текущие цены.

Perché copiare quando si può ottenere immediatamente il prezzo corrente?
In teoria, CopyTicks ha nelle sue viscere dei controlli di parametri aggiuntivi, aumentando così la lunghezza del codice nel corpo della funzione.
Ma SymbolInfoTick non ha parametri aggiuntivi, e in teoria, l'implementazione di questa funzione dovrebbe contenere meno codice.
Meno codice significa un'esecuzione più veloce.

L'unica cosa negativa è che la funzione SymbolInfoTick non ha una documentazione dettagliata simile a CopyTicks e non è completamente chiaro come funziona.
Fa la cache o restituisce immediatamente i dati grezzi.

Motivazione: