Probando 'CopyTicks' - página 22

 
fxsaber:
No, por desgracia. Renat argumentó que la copa se transmite permanentemente para toda la vigilancia del mercado. Pero esta no es una solución conveniente (de despilfarro) para la mayoría de las situaciones.

Es la única opción posible. Las apuestas de streaming son un flujo nativo e inseparable de las garrapatas.

Todo en la plataforma está interconectado y requiere una sincronización global de datos. Y el flujo de garrapatas juega un papel crucial en esto.

 
Renat Fatkhullin:

Es la única opción posible. Las tasas de streaming son un flujo nativo e inseparable de las garrapatas.

Todo en la plataforma está interconectado y requiere una sincronización global de datos. Y el flujo de garrapatas juega un papel fundamental en esto.

¿Y si ningún EA está suscrito a BookEvent?

¿Recomienda recortar MarketWatch para mejorar el rendimiento?

 
Renat Fatkhullin:

Pero lo más importante es que los cálculos de la frecuencia de muestreo anteriores son irrelevantes. Están hechos con tanta torpeza (midiendo cualquier cosa menos el tiempo de los CopyTicks), que resulta hasta sorprendente.

No he mirado los cálculos de velocidad, me mediré con el método que has descrito arriba.
 
fxsaber:

¿Y si ningún EA está suscrito a BookEvent?

¿Recomienda recortar Marketwatch para mejorar el rendimiento?

Córtalo si quieres.

 
Renat Fatkhullin:

Así es como se prueban los CopyTicks:

MqlTick ExtArr[2048];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   ulong from   =(TimeTradeServer()-1200)*1000;
   ulong ticks  =GetMicrosecondCount();
   int   records=CopyTicks(_Symbol,ExtArr,COPY_TICKS_INFO,from,2048);

   ticks=GetMicrosecondCount()-ticks;
   Print("Time: ",ticks," msc for ",records," records");
  }

Aquí está la salida en microsegundos: 95 microsegundos por muestra de 2048 ticks de INFO para los últimos 20 minutos

2016.10.18 14:15:38.673 TEST (USDCHF,M1)        Time: 95 msc for 1206 records
Esto es drásticamente diferente de las decenas de milisegundos que usted afirmó. Eso es porque no estabas midiendo los CopyTicks.

Ya me comí el ojo del gato con esto. He hecho muchas pruebas con CopyTicks. Esta vez he decidido que es suficiente con ejecutar el indicador.

Su variante.

Network 'xxx': authorized on MetaQuotes-Demo through Access Point EU Amsterdam (ping: 54.84 ms)

2016.10.18 14:29:11.966 Test14 (GBPUSD,M1)      Time: 20263 msc for 2048 records
2016.10.18 14:29:10.841 Test14 (GBPUSD,M1)      Time: 13190 msc for 2048 records
2016.10.18 14:29:07.788 Test14 (GBPUSD,M1)      Time: 13344 msc for 2048 records
2016.10.18 14:29:07.738 Test14 (GBPUSD,M1)      Time: 12751 msc for 2048 records
 

Se trata de entrar en un caché cercano a las últimas 4096 cotizaciones.

Cualquier cosa que entre en él tarda microsegundos, y cualquier cosa más larga requiere acceder al historial (incluido el disco).

Por lo tanto, mi ejemplo de búsqueda de ticks durante 20 minutos en el USDCHF, que rara vez se actualiza, estaba en la caché, pero en el GBPUSD, ya superó los últimos 4096 ticks y tuvo que ir a la base de datos lejana.

Si establezco ulong de =(TimeTradeServer()-600)*1000, entonces se ajustará en GBPUSD también.

 
Renat Fatkhullin:

Se trata de entrar en un caché cercano a las últimas 4096 cotizaciones.

Cualquier cosa que entre en él tarda microsegundos, y cualquier cosa más requiere acceso al historial (incluido el disco).

En su demo, este es efectivamente el caso. En BCS no lo hace.

Network 'xxx': authorized on BCS-MetaTrader5 through Access Server #2 (ping: 46.66 ms)


2016.10.18 15:12:32.949 Test14 (Si-12.16,M1)    Time: 29089 msc for 1503 records
2016.10.18 15:12:32.822 Test14 (Si-12.16,M1)    Time: 33207 msc for 1501 records
2016.10.18 15:12:32.639 Test14 (Si-12.16,M1)    Time: 21389 msc for 1500 records
2016.10.18 15:12:31.959 Test14 (Si-12.16,M1)    Time: 21926 msc for 1500 records

Y en Alpari no es nada bueno.

Network 'xxx': authorized on Alpari-MT5 through mt5.nl.3 (ping: 61.87 ms)

2016.10.18 15:14:47.159 Test14 (GBPUSD,M1)      Time: 31086 msc for 1836 records
2016.10.18 15:14:46.999 Test14 (GBPUSD,M1)      Time: 30698 msc for 1836 records
2016.10.18 15:14:46.779 Test14 (GBPUSD,M1)      Time: 46306 msc for 1836 records
2016.10.18 15:14:46.612 Test14 (GBPUSD,M1)      Time: 30440 msc for 1836 records
2016.10.18 15:14:46.532 Test14 (GBPUSD,M1)      Time: 36227 msc for 1836 records

Por lo tanto, mi ejemplo de buscar ticks durante 20 minutos en el USDCHF, que se actualiza raramente, cabe en la caché, pero para el GBPUSD ya ha superado los últimos 4096 ticks y me obliga a ir a una base de datos lejana.

Comentado anteriormente sobre los inconvenientes de copytix. El indicador presentado se ralentiza debido a que se ve obligado a llamar a copyix varias veces. Y todos los retrasos se deben a ello. Esta es la razón

Foro sobre comercio, sistemas de comercio automatizados y prueba de estrategias de comercio

Probando 'CopyTicks'

fxsaber, 2016.10.11 19:23

¿Cuál es el algoritmo óptimo (más rápido) para obtener los ticks de_tiempo a_tiempo?

Se ha propuesto una solución

Foro sobre trading, sistemas de trading automatizados y pruebas de estrategias de trading

Probando 'CopyTicks'

fxsaber, 2016.10.12 08:44

Cuando no es cero Desde dentro CopyTicks está buscando (probablemente una búsqueda binaria) un lugar para empezar - un índice en la base interna.

Por favor, añada una función que devuelva el índice en la base de datos por tiempo. Entonces, esta tarea se podrá resolver de forma óptima

Ahora, para descargar los ticks entre las fechas, debemos hacer peticiones de un número DESCONOCIDO de ticks, a partir de la fecha de inicio. Y luego comprobar cada vez, si ha llegado a la fecha de finalización. Y teniendo en cuenta el hecho, que cada solicitud copytix es muy caro, y se obtiene tales frenos.

 
fxsaber:

Y en Alpari no es nada bueno

Parece que Alpari se ha arreglado. La BCS no lo ha hecho.

Sería bueno tener un caché de los datos copiados solicitados anteriormente. Bueno, y si la copia se hace en varios pasos (de[i] a de[i+ 1]), lo lógico sería almacenar en caché mucho después de la primera petición.

En definitiva, no está claro cómo se organiza la función internamente. Pero es difícil trabajar con él, al 100%.

 
Asesor
long LastTime = 0; // time_msc-время последнего тика (самого свежего), полученного из истории
int Count = 0;     // Количество тиков в последенем запросе, у которых time_msc == LastTime

// Возвращает свежие тики, пришедшие после предыдущего вызова
int GetFreshTicks( MqlTick &Ticks[], const uint flags = COPY_TICKS_INFO, const uint count = 2000 )
{
  int Res = 0;

  MqlTick NewTicks[];
  const int NewAmount = CopyTicks(Symbol(), NewTicks, flags, LastTime, count);

  if ((NewAmount > 0) && (Count < NewAmount))
  {
    Res = ArrayCopy(Ticks, NewTicks, 0, Count);

    // Взяли крайнее время из текущей истории
    LastTime = NewTicks[NewAmount - 1].time_msc;
    Count = 1;

    // Находим (Count) в текущей истории количество тиков со временем LastTime
    for (int i = NewAmount - 2; i >= 0; i--)
    {
      if (NewTicks[i].time_msc < LastTime)
        break;

      Count++;
    }
  }

  return(Res);
}

#define TOSTRING(A) " " + #A + " = " + (string)(A)

void OnTick( void )
{
  // возьмем тики с начала утренней сессии
  LastTime = (TimeCurrent() - (TimeCurrent() % (24 * 3600))) * 1000;
  
  MqlTick Ticks[];

  int i = 0;
  int Sum = 0;

  const ulong StartTime  =GetMicrosecondCount();
  
  // Взяли свеженькие тики
  int Amount = GetFreshTicks(Ticks);
    
  while (Amount > 0)
  {
    Sum += Amount;
    i++;
    
    Print(TOSTRING(i) + TOSTRING(Amount) + TOSTRING(Sum) + TOSTRING(GetMicrosecondCount() - StartTime));
    
    // Взяли свеженькие тики  
    Amount = GetFreshTicks(Ticks);    
  }  
}
Resultado en Metaquotes-demo
2016.10.18 16:06:18.744 Test15 (GBPUSD,M1)       i = 40 Amount = 1453 Sum = 79414 GetMicrosecondCount()-StartTime = 584393
2016.10.18 16:06:18.744 Test15 (GBPUSD,M1)       i = 39 Amount = 1999 Sum = 77961 GetMicrosecondCount()-StartTime = 584314
2016.10.18 16:06:18.729 Test15 (GBPUSD,M1)       i = 38 Amount = 1999 Sum = 75962 GetMicrosecondCount()-StartTime = 568509
2016.10.18 16:06:18.714 Test15 (GBPUSD,M1)       i = 37 Amount = 1999 Sum = 73963 GetMicrosecondCount()-StartTime = 552582
2016.10.18 16:06:18.696 Test15 (GBPUSD,M1)       i = 36 Amount = 1999 Sum = 71964 GetMicrosecondCount()-StartTime = 536790
2016.10.18 16:06:18.681 Test15 (GBPUSD,M1)       i = 35 Amount = 1999 Sum = 69965 GetMicrosecondCount()-StartTime = 520432
2016.10.18 16:06:18.666 Test15 (GBPUSD,M1)       i = 34 Amount = 1999 Sum = 67966 GetMicrosecondCount()-StartTime = 504725
2016.10.18 16:06:18.649 Test15 (GBPUSD,M1)       i = 33 Amount = 1999 Sum = 65967 GetMicrosecondCount()-StartTime = 488911
2016.10.18 16:06:18.634 Test15 (GBPUSD,M1)       i = 32 Amount = 1999 Sum = 63968 GetMicrosecondCount()-StartTime = 473372
2016.10.18 16:06:18.619 Test15 (GBPUSD,M1)       i = 31 Amount = 1999 Sum = 61969 GetMicrosecondCount()-StartTime = 458022
2016.10.18 16:06:18.604 Test15 (GBPUSD,M1)       i = 30 Amount = 1999 Sum = 59970 GetMicrosecondCount()-StartTime = 442557
2016.10.18 16:06:18.589 Test15 (GBPUSD,M1)       i = 29 Amount = 1999 Sum = 57971 GetMicrosecondCount()-StartTime = 427044
2016.10.18 16:06:18.571 Test15 (GBPUSD,M1)       i = 28 Amount = 1999 Sum = 55972 GetMicrosecondCount()-StartTime = 411524
2016.10.18 16:06:18.556 Test15 (GBPUSD,M1)       i = 27 Amount = 1999 Sum = 53973 GetMicrosecondCount()-StartTime = 396539
2016.10.18 16:06:18.541 Test15 (GBPUSD,M1)       i = 26 Amount = 1999 Sum = 51974 GetMicrosecondCount()-StartTime = 381185
2016.10.18 16:06:18.526 Test15 (GBPUSD,M1)       i = 25 Amount = 1999 Sum = 49975 GetMicrosecondCount()-StartTime = 366146
2016.10.18 16:06:18.511 Test15 (GBPUSD,M1)       i = 24 Amount = 1999 Sum = 47976 GetMicrosecondCount()-StartTime = 351066
2016.10.18 16:06:18.496 Test15 (GBPUSD,M1)       i = 23 Amount = 1999 Sum = 45977 GetMicrosecondCount()-StartTime = 336183
2016.10.18 16:06:18.481 Test15 (GBPUSD,M1)       i = 22 Amount = 1999 Sum = 43978 GetMicrosecondCount()-StartTime = 321109
2016.10.18 16:06:18.466 Test15 (GBPUSD,M1)       i = 21 Amount = 1999 Sum = 41979 GetMicrosecondCount()-StartTime = 306119
2016.10.18 16:06:18.449 Test15 (GBPUSD,M1)       i = 20 Amount = 1999 Sum = 39980 GetMicrosecondCount()-StartTime = 288558
2016.10.18 16:06:18.434 Test15 (GBPUSD,M1)       i = 19 Amount = 1999 Sum = 37981 GetMicrosecondCount()-StartTime = 273758
2016.10.18 16:06:18.419 Test15 (GBPUSD,M1)       i = 18 Amount = 1999 Sum = 35982 GetMicrosecondCount()-StartTime = 259255
2016.10.18 16:06:18.406 Test15 (GBPUSD,M1)       i = 17 Amount = 1999 Sum = 33983 GetMicrosecondCount()-StartTime = 244750
2016.10.18 16:06:18.391 Test15 (GBPUSD,M1)       i = 16 Amount = 1999 Sum = 31984 GetMicrosecondCount()-StartTime = 230100
2016.10.18 16:06:18.371 Test15 (GBPUSD,M1)       i = 15 Amount = 1999 Sum = 29985 GetMicrosecondCount()-StartTime = 216143
2016.10.18 16:06:18.361 Test15 (GBPUSD,M1)       i = 14 Amount = 1999 Sum = 27986 GetMicrosecondCount()-StartTime = 201830
2016.10.18 16:06:18.346 Test15 (GBPUSD,M1)       i = 13 Amount = 1999 Sum = 25987 GetMicrosecondCount()-StartTime = 186887
2016.10.18 16:06:18.331 Test15 (GBPUSD,M1)       i = 12 Amount = 1999 Sum = 23988 GetMicrosecondCount()-StartTime = 172667
2016.10.18 16:06:18.311 Test15 (GBPUSD,M1)       i = 11 Amount = 1999 Sum = 21989 GetMicrosecondCount()-StartTime = 158356
2016.10.18 16:06:18.299 Test15 (GBPUSD,M1)       i = 10 Amount = 1999 Sum = 19990 GetMicrosecondCount()-StartTime = 143450
2016.10.18 16:06:18.289 Test15 (GBPUSD,M1)       i = 9 Amount = 1999 Sum = 17991 GetMicrosecondCount()-StartTime = 128520
2016.10.18 16:06:18.269 Test15 (GBPUSD,M1)       i = 8 Amount = 1999 Sum = 15992 GetMicrosecondCount()-StartTime = 114209
2016.10.18 16:06:18.256 Test15 (GBPUSD,M1)       i = 7 Amount = 1999 Sum = 13993 GetMicrosecondCount()-StartTime = 100016
2016.10.18 16:06:18.246 Test15 (GBPUSD,M1)       i = 6 Amount = 1999 Sum = 11994 GetMicrosecondCount()-StartTime = 85745
2016.10.18 16:06:18.231 Test15 (GBPUSD,M1)       i = 5 Amount = 1999 Sum = 9995 GetMicrosecondCount()-StartTime = 71438
2016.10.18 16:06:18.219 Test15 (GBPUSD,M1)       i = 4 Amount = 1999 Sum = 7996 GetMicrosecondCount()-StartTime = 57293
2016.10.18 16:06:18.204 Test15 (GBPUSD,M1)       i = 3 Amount = 1999 Sum = 5997 GetMicrosecondCount()-StartTime = 43192
2016.10.18 16:06:18.181 Test15 (GBPUSD,M1)       i = 2 Amount = 1999 Sum = 3998 GetMicrosecondCount()-StartTime = 28943
2016.10.18 16:06:18.171 Test15 (GBPUSD,M1)       i = 1 Amount = 1999 Sum = 1999 GetMicrosecondCount()-StartTime = 15160
80K ticks en medio segundo - ¡lento! Decir que deberíamos haber pedido más garrapatas en lugar de 2000 garrapatas a la vez es, por supuesto, posible. ¿Cuál es entonces el valor óptimo de la solicitud?
 
fxsaber:
¡80K ticks en medio segundo es lento! Decir que era necesario solicitar no 2000 garrapatas a la vez, pero más, por supuesto, es posible. ¿Qué valor de solicitud es entonces el óptimo?

Lo óptimo es descargar una vez lo que se necesita para profundizar, y luego sólo descargar los nuevos de la caché cercana en microsegundos.

Si cada vez que haces consultas profundas con caer al disco, entonces por supuesto que es tu culpa.

Razón de la queja: