Tiki em tempo real - página 12

 
Sergey Chalyshev:

Gostaria de lembrar que a OnTick recebe duas linhas independentes, informação e comércio,COPY_TICKS_INFO e COPY_TICKS_ALL e passa por um pré-processamento .

Estas linhas não estão sincronizadas entre si, portanto, se você comparar OnBookEvent com OnTick, você deve tomarTICKS_INFO.

Por definição, o OnBookEvent deve ser mais rápido, uma vez que não passa pelo pré-processamento.

Os testes não determinam com segurança quem é mais rápido, pois não sabemos o tempo de estoque do tick.

Embora tenhamos pedido muitas vezes aos desenvolvedores para ADICIONAR O TEMPO STOCK! ! !


p.s. além da velocidade, o tumblr também tem vantagens sobre o OnTick,

como já foi dito, não é possível obter melhores preços de compra e venda na OnTick,

eOnTick não tem dados de outros símbolos, é inútil para os Consultores Especialistas analisarem vários símbolos.


mudouCOPY_TICKS_ALL paraCOPY_TICKS_INFO

Resultado

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 

Marcado em amarelo - o mesmo carrapato!

Afinal, provavelmente há uma imprecisão no código...?
 

Por um segundo, parecia que você tinha um desejo de resolver as coisas e isso ajudaria a temperar seu orgulho.
Não, apenas parecia que sim.

Em geral, a questão é resolvida, e qualquer um pode observar o seu e o do fxsaber e meus códigos, e tirar conclusões.
Com você eu paro de dialogar, nada a não ser gritos altos vindos de você, e ao receber as informações seu cérebro não funciona em absoluto.

Boa sorte com a FORTS.

 
Sergey Chalyshev:

Gostaria de lembrar que a OnTick recebe duas linhas independentes, informação e comércio,COPY_TICKS_INFO e COPY_TICKS_ALL e passa por um pré-processamento .

Estas linhas não estão sincronizadas entre si, portanto, se você comparar OnBookEvent com OnTick, você deve tomarTICKS_INFO.

Sergei, usamos On-functions simplesmente como um ponto de entrada.

A questão era qual ponto de entrada viria primeiro (dando as mesmas informações corretas sobre o último tick).

Execute minha EA, e veja o registro. A hora do evento (exata até ms) e a hora do último tick conhecido (também com ms) são emitidas no log.

Basta analisar alguns carrapatos individuais para "quem está mais adiantado".


Sergey Chalyshev:

OnBookEvent deve, por definição, ser mais rápido, pois não passa pelo pré-processamento.

Eu não acho que a OnTick tenha. E os testes o confirmam, não há qualquer atraso.


Sergey Chalyshev:

Como já foi dito, é impossível melhorar o Bid and Ask price no OnTick.

Possivelmente com CopyTicks.

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

Execute minha EA, e veja o registro. A hora do evento (exata até ms) e a hora do último tick conhecido (também com ms) são emitidas para o log.

Basta analisar alguns carrapatos individuais para ver "quem veio primeiro".

Uma situação comum é quando o OnBook chega ao mesmo tempo que o OnTick ou 1-2ms mais tarde. Mas também há desfasamentos:


 

Dentro de 5 horas:

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

O dobro dos eventos OnBook. Pena que nem todos eles carreguem uma carga útil (se for necessária a melhor oferta/pesquisa e barbatana caudal).

 
Andrey Khatimlianskii:

Sergey, estamos usando as On-funções simplesmente como um ponto de entrada.

A questão era qual ponto de entrada viria primeiro (dando as mesmas informações corretas sobre o último tick).

Execute minha EA, e veja o registro. A hora do evento (exata até ms) e a hora do último tick conhecido (também com ms) são emitidas no log.

Basta analisar alguns carrapatos individuais para "quem está mais adiantado".

Isto é você fazendo errado. Talvez o evento do tumblr tenha chegado, mas ainda não tenha entrado na história da carraça. Você deveria estar comparando os preços Bid Ask, não mergulhando na história do tick.

Eu não acho que OnTick passe. E os testes o confirmam, não há atraso.

Antes de entrar na história, os carrapatos são necessariamente processados e também distribuídos para todos os gráficos, indicadores e Consultores Especialistas necessários. E tudo isso em MT5 é feito sequencialmente (não em paralelo).

Talvez com a ajuda de CopyTicks.

Não, comCopyTicks também é impossível obter o melhor preço, e se for o seu pedido que se mantém o melhor.
 

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

Eu tenho uma maneira diferente de fazer as coisas:

carrapato vs livro

As linhas azuis são OnBook,

Os vermelhos são OnCalculat = OnTick.

Se você estiver interessado, posso lhe mostrar o código

 
Sergey Chalyshev :

Eu entendo diferente:


linhas azuis são OnBook ,

OnTick vermelho.

Se estiver interessado, posso mostrar o código do indicador

Não Serezha!

Deve-se admitir que OnBookEvent() e OnTick() todos os ticks são os mesmos (eu tive um bug no código),

mas outras alterações do DOM não são refletidas no OnTick() de forma alguma

Isso não é importante para os comerciantes FOREX. (Citação cautelosa da mensagem acima: " Há 2 vezes mais eventos OnBook. É uma pena que nem todos eles carreguem uma carga útil (se você precisar de um melhor lance/ask e um último)" . )

Código corrigido:

 //+------------------------------------------------------------------+
//|                                                   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:

Sem Seryozh!

Tenho que admitir que OnBookEvent() e OnTick() todos os carrapatos coincidem (eu tive um erro no código),

mas outras mudanças no vidro não são refletidas no OnTick()

Para as pessoas da FOREX não importa (Citação cautelosa do post acima: "2 vezes mais eventos OnTick".Pena que nem todos eles carreguem uma carga útil (se você precisar de melhor lance/pesquisa e flipper)".)

Código corrigido:

Resultado (trecho).

É claro que os bilhetes na história vão coincidir, mas na figura acima, acontece que nem todos os info-ticks ficam na história ou são pulados na OnCalculat.

Não sei se há um erro, tentarei corrigi-lo na segunda-feira.

 
prostotrader:


Ou talvez em tempo real, em vez de

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

uso

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

Por que copiar quando você pode obter imediatamente o preço atual?
Em teoria, CopyTicks tem em suas tripas verificações de parâmetros extras, aumentando assim o comprimento do código no corpo da função.
Mas SymbolInfoTick não tem parâmetros adicionais, e em teoria, a implementação desta função deve conter menos código.
Menos código significa execução mais rápida.

A única coisa ruim é que a função SymbolInfoTick não possui documentação detalhada semelhante a CopyTicks e não está completamente claro como ela funciona.
Faz o cache, ou devolve os dados brutos imediatamente.

Razão: