Errors, bugs, questions - page 2010

 
Andrey Dik:
in the CopyTicks tester returns zeros, is this normal?
Are you testing, by any chance, in OHLC M1 mode or opening prices?
 
Alexey Kozitsyn:
Are you testing, by any chance, in OHLC M1 mode or opening prices?
No, I've tried both "ticks" and "real ticks", sometimes the structure array is full of zeros, sometimes partially.
 

Please, someone try this EA in the tester in different test modes:

//——————————————————————————————————————————————————————————————————————————————
input  int                     AveTicksPeriod_P       = 20;

MqlTick G_Ticks [];

//——————————————————————————————————————————————————————————————————————————————
int OnInit ()
{
  // сделаем начальную синхронизацию
  GetLastRequredTicks (Symbol (), AveTicksPeriod_P, G_Ticks, true, COPY_TICKS_INFO, 0);

  return (INIT_SUCCEEDED);
}
//——————————————————————————————————————————————————————————————————————————————

//——————————————————————————————————————————————————————————————————————————————
void OnTick ()
{
  Print ("---------------------");

  if(!GetLastRequredTicks (Symbol (), AveTicksPeriod_P, G_Ticks, true, COPY_TICKS_INFO, 0))
  {
    Print ("Ошибка получения тиков " + (string)ArraySize (G_Ticks));
    return;
  }

  int errors = 0;

  for(int i = 0; i < AveTicksPeriod_P; i++)
    if(G_Ticks [i].bid <= 0.0)
    {
      Print (G_Ticks [i].bid);
      errors++;
    }
  
  if(errors > 0)
    Print ("errors: " + (string)errors);
}
//——————————————————————————————————————————————————————————————————————————————

//——————————————————————————————————————————————————————————————————————————————
// Получение последних тиков c в указанном количестве,
// попытки в течении указанного времени в мс
bool GetLastRequredTicks (string   symbol,                 //символ
                          int      count,                  //количество
                          MqlTick &ticks [],                //массив для приёма тиков
                          bool     timeseries = true,      //0-й элемент самый свежий или нет
                          uint     flag = COPY_TICKS_INFO, //COPY_TICKS_INFO или COPY_TICKS_TRADE или COPY_TICKS_ALL
                          ulong    waitMs = 0)             //отведённое время на получение в мкс (10(-6)с)
{
  //---
  bool    success = false;   // флаг успешного выполнения копирования тиков
  MqlTick tick_array [];     // массив для приема тиков
  if(timeseries)
    ArraySetAsSeries (ticks, timeseries);
  ZeroMemory (tick_array);
  ulong startTime   = GetMicrosecondCount ();
  ulong timeElapsed = 0; // мкс
  int   received    = 0;

  ResetLastError ();
  bool wait = true;

  while(wait)
  {
    //--- запросим тиковую историю последних тиков в указанном количестве
    received = CopyTicks (symbol, ticks, flag, 0, count);

    timeElapsed = GetMicrosecondCount () - startTime;

    // если указано допустимое время на синхронизацию
    if(waitMs > 0)
    {
      // если время превысило допустимое, то попыток больше не будет
      if(timeElapsed >= waitMs)
        wait = false;
    }

    if(received == count)
    {
      //--- выведем информацию о количестве тиков и затраченном времени времени
      //PrintFormat ("%s: received %d ticks in %d mcs", _Symbol, received, timeElapsed);

      return (true);
    }

    //--- пауза в 0.1 секунду в ожидании завершения синхронизации тиковой базы
    Sleep (100);
  }

  return (false);
}
//——————————————————————————————————————————————————————————————————————————————


The point of it is to get a specified number of the freshest ticks on each tick. zeros come out, for crying out loud.

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии ( советники ) перед началом использования их в реальной торговле. При...
 
Andrey Dik:

Please, someone try this EA in the tester in different test modes:


The point of it is to get a specified number of the freshest ticks on each tick. zeros come out, for crying out loud.


Ticks   EURUSD: ticks synchronization started
OE      0       00:31:42.376    Ticks   EURUSD: load 34 bytes of tick data to synchronize in 0:00:00.000
KP      0       00:31:42.376    Ticks   EURUSD: history ticks synchronized from 2017.07.16 to 2017.09.20
DK      0       00:31:42.442    History EURUSD,M15: history cached from 2016.01.03 23:00
CK      0       00:31:42.442    Tester  EURUSD,M15 (): generating based on real ticks
MS      0       00:31:42.442    Tester  EURUSD,M15: testing of Experts\test_getTicks.ex5 from 2017.09.20 00:00 to 2017.09.21 00:00 started with inputs:
CO      0       00:31:42.442    Tester    AveTicksPeriod_P=20
HH      0       00:31:42.681    Ticks   EURUSD : real ticks begin from 2017.07.16 00:00:00
EL      3       00:31:42.681    Ticks   EURUSD : 2017.09.20 00:00 - 2017.09.21 00:00  last prices translation turned on for 1333 minute bars
PN      0       00:31:42.682    test_getTicks (EURUSD,M15)      2017.09.20 00:00:19   ---------------------
IE      0       00:31:42.763    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   ---------------------
LE      0       00:31:42.877    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   0.0
RP      0       00:31:42.877    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   errors: 1
FG      0       00:31:42.878    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   ---------------------
HG      0       00:31:42.949    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   0.0
FR      0       00:31:42.949    test_getTicks (EURUSD,M15)      2017.09.20 00:00:23   errors: 1
RI      0       00:31:42.950    test_getTicks (EURUSD,M15)      2017.09.20 00:00:24   ---------------------
 
Andrey Dik:

Please, someone try this EA in the tester in different test modes:


The point of it is to get a specified number of the freshest ticks on each tick. zeros come out, for crying out loud.

I managed to get it on FORTS, but only a TRADE-flow (using an indicator). Your Expert Advisor does not even want to run on real ticks...
 
Alexey Kozitsyn:
On FORTS I managed to get, but only a TRADE - flow (using an indicator). Your expert doesn't even want to run on real ticks...

yes, there is a problem. but where? what exactly is the problem, that is the question.

But one time there was an error.

 
Andrey Dik:

Please, someone try this EA in the tester in different test modes:


The essence of it is to get a specified number of the freshest ticks on each tick.

Well, if you want the freshest ticks, you should not take them from zero, but from the current time in milliseconds.

    received = CopyTicks (symbol, ticks, flag, TimeCurrent()*1000, count);
 
Alexey Viktorov:

Well, if you want fresh ticks, you should not take them from zero, but from the current time in milliseconds.

The help says:

from

[in] Date from which the ticks are requested. Specified in milliseconds from 01.01.1970. If from=0, the last count of ticks is given .

 

I save mq5-file in Metaeditor, but its old version is saved (time varies). In this case ex5 at compilation corresponds to what I see in ME. But when I close ME, all data in file will be lost.

Trying to save it under different name - file is created, but there is old source - not the one I see in ME. There is definitely room on the drive.

 
Comments not relevant to this topic have been moved to "Why the EA does not work".
Reason: