Probando 'CopyTicks' - página 24

 
Alexey Kozitsyn:

¿Por qué?

int  CopyTicks(
   string           symbol_name,           // имя символа
   MqlTick&         ticks_array[],         // массив для приёма тиков
   uint             flags=COPY_TICKS_ALL,  // флаг, определяющий тип получаемых тиков
   ulong            from=0,                // дата, начиная с которой запрашиваются тики
   uint             count=0                // количество тиков, которые необходимо получить
   );
Resaltado en negrita. El array del final es un rechazo de los valores por defecto.
 
fxsaber:
int  CopyTicks(
   string           symbol_name,           // имя символа
   MqlTick&         ticks_array[],         // массив для приёма тиков
   uint             flags=COPY_TICKS_ALL,  // флаг, определяющий тип получаемых тиков
   ulong            from=0,                // дата, начиная с которой запрашиваются тики
   uint             count=0                // количество тиков, которые необходимо получить
   );
Resaltado en negrita.
No se ha destacado, pero probablemente se ha respondido más arriba...
 
fxsaber:
int  CopyTicks(
   string           symbol_name,           // имя символа
   MqlTick&         ticks_array[],         // массив для приёма тиков
   uint             flags=COPY_TICKS_ALL,  // флаг, определяющий тип получаемых тиков
   ulong            from=0,                // дата, начиная с которой запрашиваются тики
   uint             count=0                // количество тиков, которые необходимо получить
   );
Lo pongo en negrita. Array al final - evitar los valores por defecto.

Sí, el tamaño de los ticks en la caché se puede asignar explícitamente en la documentación. Si quieres obtener todo el caché - mira la documentación y pide el número requerido con la función, con parámetros como aquí:

intCopiarBuffer(
intindicator_handle,// Manejador del indicador
intbuffer_num,// número del buffer indicador
intstart_pos,//donde empezar
intcount,// cuántos copiamos
doublebuffer[]// matriz donde se copiarán los datos
);

Todo está ya inventado, ¿por qué hay que inventar algo nuevo?

 
Alexey Kozitsyn:

Creo que es mucho más importante hacer una descarga de fecha a fecha que intentar mantener la configuración por defecto.

Así que de fecha a fecha será. CopyTicks tratando de coincidir en la sintaxis con Copy-funciones sólo por la presencia de Copy en el nombre no es conveniente. Conveniente y justificado es cuando puedes hacer cosas de preprocesador como esta

// Позволяет, как в MT4, работать с таймсериями: Open[Pos], High[Pos], Low[Pos], Close[Pos], Time[Pos], Volume[Pos].
// А так же задает привычные MT4-функции: iOpen, iHigh, iLow, iClose, iTime, iVolume.
#define DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get( const string Symb, const int TimeFrame, const int iShift )                                  \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator []( const int iPos ) const                                                                     \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  };                                                                                                          \
                                                                                                              \
  CLASS##NAME NAME;                                                                                           \
                                                                                                              \
  T i##NAME( const string Symb, const int TimeFrame, const int iShift )                                       \
  {                                                                                                           \
    return(CLASS##NAME::Get(Symb, TimeFrame, iShift));                                                        \
  }

DEFINE_TIMESERIE(Volume, TickVolume, long)
DEFINE_TIMESERIE(Time, Time, datetime)
DEFINE_TIMESERIE(Open, Open, double)
DEFINE_TIMESERIE(High, High, double)
DEFINE_TIMESERIE(Low, Low, double)
DEFINE_TIMESERIE(Close, Close, double)
Y no se puede hacer para CopyTicks porque hay dos hilos físicos diferentes (TRADE e INFO) y un hilo sintético (ALL) - banderas.
 
fxsaber:

Así que de fecha a fecha será. CopyTicks tratando de hacer coincidir la sintaxis con las funciones de copia sólo por la presencia de Copy en el nombre no es conveniente. Conveniente y justificado es cuando puedes hacer cosas de preprocesador como esta.

#define DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get( const string Symb, const int TimeFrame, const int iShift )                                  \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator []( const int iPos ) const                                                                     \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  };                                                                                                          \
                                                                                                              \
  CLASS##NAME NAME;                                                                                           \
                                                                                                              \
  T i##NAME( const string Symb, const int TimeFrame, const int iShift )                                       \
  {                                                                                                           \
    return(CLASS##NAME::Get(Symb, TimeFrame, iShift));                                                        \
  }

DEFINE_TIMESERIE(Volume, TickVolume, long)
DEFINE_TIMESERIE(Time, Time, datetime)
DEFINE_TIMESERIE(Open, Open, double)
DEFINE_TIMESERIE(High, High, double)
DEFINE_TIMESERIE(Low, Low, double)
DEFINE_TIMESERIE(Close, Close, double)
Y para CopyTicks no se puede hacer este tipo de cosas, porque hay dos hilos físicos diferentes (TRADE e INFO) y uno sintético (ALL) - banderas.

Antes de que aparecieras en el foro, no había encontrado esta forma de escribir, por lo que, por supuesto, te doy las gracias, pero no estoy seguro de que muchos programadores la encuentren útil.

 
fxsaber:

En su demo, efectivamente lo es. En BCS no lo es.

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

Ya se habló de los inconvenientes de copytix. El indicador presentado se ralentiza debido a que tengo que llamar a copytix varias veces. Y todos los retrasos se deben a ello. La cuestión es la siguiente

Se ha propuesto la solución.

Ahora, para descargar los ticks entre las fechas, hay que hacer solicitudes para cualquier número de ticks, a partir de la fecha inicial. Y luego mira cada vez, y si llegó a la fecha de finalización. Y teniendo en cuenta que cada solicitud de copytix es muy cara, y que te dan esos frenos.

Datos de la apertura real, sólo se cargan los ticks frescos:

2016.10.20 18:47:06.499 GetTickHistory: Получено 4 тиков за 46 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.499 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.499 GetTickHistory: Получено 3 тиков за 20 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.499 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.499 GetTickHistory: Получено 3 тиков за 19 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.499 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.540 GetTickHistory: Получено 8 тиков за 107 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.540 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.540 GetTickHistory: Получено 5 тиков за 19 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.540 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.540 GetTickHistory: Получено 5 тиков за 19 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.540 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
2016.10.20 18:47:06.540 GetTickHistory: Получено 5 тиков за 18 мкс (пинг = 62214 мкс)
2016.10.20 18:47:06.540 GetTickHistory: Получены все доступные тики. Время [0]: 2016.10.20 16:47
¡COPY_TICKS_TRADE!
 
¿CopiarTicks() parece ser una función asíncrona? A menudo llegan ticks para velas que aún no se han abierto...
 
Alexey Kozitsyn:
¿CopiarTicks() parece ser una función asíncrona?
Sí.
 
Me gustaría que los desarrolladores me informaran sobre CopyTicks() en tester... Tengo malas sospechas al respecto. ¡Estoy interesado de nuevo en trabajar con COPY_TICKS_TRADE!
 

Cansado de la terminal. El guión

void OnStart()
{
  MqlTick Ticks[];
  
  Print(CopyTicks(_Symbol, Ticks));
  Print(GetLastError());
}

cuelga. Si se borra manualmente, se cerrará la sesión.

2016.10.28 16:48:57.737 Test (GBPUSD,M1)        4401
2016.10.28 16:48:57.737 Test (GBPUSD,M1)        -1

Cambio de TF y símbolo - similar. Después de reiniciar funciona.