CopyTicksRange () non funziona correttamente in MQL5. a - pagina 3

 
fxsaber #:

Unità.

Probabilmente sì, ma è comunque una funzione di base e se il terminale stesso la usa, almeno per esportare i dati, mina anche la credibilità del terminale

 

Esempi di errori promessi nel file allegato. Sorprendentemente, Err_SymbolInfoTick2() ha funzionato correttamente per un po', ma poi ha iniziato a restituire anche la data nulla. Ci sono commenti esplicativi nel codice.

Diario:

2021.09.19 06:01:24.674 ErrorCopyTicks (CustomBR,H1)    ---------Err_CopyTicksRange()------------
2021.09.19 06:01:24.754 ErrorCopyTicks (CustomBR,H1)    CopyTicksRange('@BR',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 2021.01.31 23:59:00:000 );  received 109425 ticks
2021.09.19 06:01:24.754 ErrorCopyTicks (CustomBR,H1)    2021.01.29 00:02:14:782 - first tick, 2021.01.29 23:56:43:863 - last tick
2021.09.19 06:01:24.754 ErrorCopyTicks (CustomBR,H1)    ---------------------
2021.09.19 06:01:24.754 ErrorCopyTicks (CustomBR,H1)    ---------Err_CopyTicks()------------
2021.09.19 06:01:24.767 ErrorCopyTicks (CustomBR,H1)    CopyTicks('@BR',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 100 );  received 100 ticks
2021.09.19 06:01:24.767 ErrorCopyTicks (CustomBR,H1)    2021.01.29 00:02:14:782 - first tick, 2021.01.29 10:00:12:292 - last tick
2021.09.19 06:01:24.767 ErrorCopyTicks (CustomBR,H1)    ---------------------
2021.09.19 06:01:24.767 ErrorCopyTicks (CustomBR,H1)    ---------Err_CopyTicks()------------
2021.09.19 06:01:24.906 ErrorCopyTicks (CustomBR,H1)    CopyTicks('@BR',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 1000000 );  received 1000000 ticks
2021.09.19 06:01:24.906 ErrorCopyTicks (CustomBR,H1)    2021.01.29 00:02:14:782 - first tick, 2021.02.08 14:17:58:484 - last tick
2021.09.19 06:01:24.906 ErrorCopyTicks (CustomBR,H1)    ---------------------
2021.09.19 06:01:24.906 ErrorCopyTicks (CustomBR,H1)    ---------Err_SymbolInfoTick1('CustomBR')------------
2021.09.19 06:01:24.969 ErrorCopyTicks (CustomBR,H1)    CopyTicksRange('CustomBR',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 189530 ticks
2021.09.19 06:01:24.969 ErrorCopyTicks (CustomBR,H1)    2021.09.17 00:02:12:052 - first tick, 2021.09.17 19:59:59:782 - last tick
2021.09.19 06:01:25.029 ErrorCopyTicks (CustomBR,H1)    CustomTicksReplace('CustomBR',2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000, Ticks, 189530  );  replaced 189530 ticks
2021.09.19 06:01:25.029 ErrorCopyTicks (CustomBR,H1)    ret=1, mt.time_msc=1970.01.01 00:00:00:000
2021.09.19 06:01:25.029 ErrorCopyTicks (CustomBR,H1)    ---------------------
2021.09.19 06:01:25.029 ErrorCopyTicks (CustomBR,H1)    ---------Err_SymbolInfoTick2('CustomBR')------------
2021.09.19 06:01:25.091 ErrorCopyTicks (CustomBR,H1)    CopyTicksRange('CustomBR',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 189530 ticks
2021.09.19 06:01:25.091 ErrorCopyTicks (CustomBR,H1)    2021.09.17 00:02:12:052 - first tick, 2021.09.17 19:59:59:782 - last tick
2021.09.19 06:01:25.153 ErrorCopyTicks (CustomBR,H1)    CustomTicksAdd('CustomBR',Ticks, 189530  );  added 189530 ticks
2021.09.19 06:01:25.153 ErrorCopyTicks (CustomBR,H1)    ret=1, mt.time_msc=1970.01.01 00:00:00:000
2021.09.19 06:01:25.153 ErrorCopyTicks (CustomBR,H1)    ---------------------


Divertimento per uno spuntino: se si guardano i tick con gli strumenti del terminale, si possono ottenere più tick di quelli registrati. (vedi foto). E se la data "prima" è ridotta al 2021.09.18 allora ce ne sono meno registrati.

File:
untitled.jpg  605 kb
 
sì, che sia un array statico o dinamico è irrilevante
 
RusPro #:

Esempi di errori promessi

Sfortunatamente, non c'è accesso a questi personaggi per riprodurli.

 
fxsaber #:

Purtroppo, nessun accesso a questi simboli da riprodurre.

è il micex. ok, proverò il forex.

 
RusPro #:

È il MICEX. OK, proverò il forex.

1. Non esiste un simbolo "@BR" su MICEX.

Sembra che tu stia usando un simbolo personalizzato.

E potrebbe esserci un errore nel crearlo.

Uso molto le funzioni CopyTicks e CopyTicksRange sui simboli originali MICEX - non ho notato alcun errore.

2. Il terminale non memorizza l'intera cronologia dei tick e la prima chiamata di funzione può restituire tick non per l'intero periodo richiesto.

Aggiunto

Ecco un esempio di un indicatore, dove carico i tick usando la funzione CopyTicksRange

//+------------------------------------------------------------------+
//|                                                   Ticks_test.mq5 |
//|                                      Copyright 2021 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_plots   1
#property indicator_buffers 1

enum IND_STAGE
{
  LOAD_TICKS = 0,
  READ_TICKS = 1,
  FILL_DATA = 2
};
struct T_DATA
{
  datetime bar_time;
  int ticks_cnt;
  MqlTick pr_bar_ticks[];
};
struct MARKET_DATA
{
  int time_cnt;
  int cnt;
  IND_STAGE stage;
  T_DATA t_data[];
  MqlTick ticks[];
  int live_cnt;
  int a_cnt;
  datetime time_array[];
};
MARKET_DATA m_data;
datetime start_time, end_time;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   end_time = datetime(SymbolInfoInteger(Symbol(), SYMBOL_EXPIRATION_TIME));
   m_data.stage = LOAD_TICKS;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator Load ticks function                             |
//+------------------------------------------------------------------+
bool LoadTicks(const datetime &a_times[])
{
  int bars = Bars(Symbol(),PERIOD_M1);
  datetime cur_time = TimeTradeServer();
  if(cur_time > end_time)
  {
    cur_time = end_time;
  }
  int result = CopyTime(Symbol(), PERIOD_M1, 0, bars, m_data.time_array);
  if(result > 0)
  {
    start_time = m_data.time_array[0];
    if(m_data.time_array[result - 1] == a_times[ArraySize(a_times) - 1])
    {
      m_data.time_cnt = result;
      result = CopyTicksRange(Symbol(), m_data.ticks, COPY_TICKS_INFO, ulong(start_time) * 1000, ulong(cur_time) * 1000);
      if(result > 0)
      {
        if(m_data.ticks[result-1].time >= m_data.time_array[m_data.time_cnt - 1]) 
        {
          m_data.cnt = result;
          return(true); 
        } else Print(__FUNCTION__, ": Не хватает тиков ", Symbol(), "!"); 
      } else Print(__FUNCTION__, ": Не получены тики по символу ", Symbol(), "!");
    } else Print(__FUNCTION__, ": Не хватает баров по символу ", Symbol(), "!");
  } else Print(__FUNCTION__, ": Не скопировано время баров по символу ", Symbol(), "!");
  return(false);
}  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,  
                 const int prev_calculated, 
                 const datetime& time[], 
                 const double& open[], 
                 const double& high[], 
                 const double& low[], 
                 const double& close[], 
                 const long& tick_volume[], 
                 const long& volume[],
                 const int& spread[] )
  {
  switch (m_data.stage)
  {
    case LOAD_TICKS:
      if(LoadTicks(time) == true)
      {
        Print("All ticks loaded.");
        m_data.stage = READ_TICKS;
        return(rates_total);
      }
      return(0);
    break;
    case READ_TICKS:
    break;
  }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
E tutto si carica bene, ma non sempre la prima volta.
 
prostotrader #:

1. Non esiste un simbolo "@BR" su MICEX

Ecco un esempio di indicatore, dove carico i tick usando la funzione CopyTicksRange

E tutto si carica bene, ma non sempre la prima volta.

Questo è un collante dei futures sul petrolio. Broker BCS. Può essere chiamato in modo diverso in diversi broker. Ma esattamente gli stessi problemi saranno su altri simboli.

 
prostotrader #:

Nel tuo esempio funziona, perché le condizioni di chiamata sono diverse - l'ora di inizio è sempre uguale all'inizio della barra esistente (cioè i tick sono noti per esistere) e si legge tutta la storia dei tick dell'ultima barra in una volta sola.

A proposito, una delle mie stampelle funziona in modo simile alla tua. All'inizio ottengo anche i tempi delle barre esistenti, poi le spezzo in segmenti continui massimi e ottengo i tick. Ma si verifica un altro problema - se non c'è abbastanza array di ricezione per i dati, il resto che riprende è una danza del tamburello (di cui ho parlato sopra).

E lavorare con gli array dinamici è molto più lento e bisogna considerare la possibile frammentazione della memoria.

 
prostotrader #:

2. Il terminale non memorizza l'intera cronologia dei tick e la prima chiamata alla funzione potrebbe non restituire i tick per l'intero periodo richiesto.

Non c'è nessun problema se non viene restituito l'intero periodo, il problema è quando viene restituito un altro periodo invece di quello richiesto. O, ancora peggio, quando restituisce quello richiesto e qualche altro tick, non incluso nell'intervallo


Ho sostituito il simbolo nel mio esempio con "SILV-12.21". Ho avuto lo stesso errore, e ciò che è interessante, SymbolInfoTick ha restituito la risposta giusta nell'ultimo test :) ma come posso indovinare, quando è sbagliato e quando è sbagliato?


2021.09.19 15:27:55.089	ErrorCopyTicks (CustomBR,H1)	---------Err_CopyTicksRange()------------
2021.09.19 15:27:55.090	ErrorCopyTicks (CustomBR,H1)	CopyTicksRange('SILV-12.21',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 2021.01.31 23:59:00:000 );  received 1758 ticks
2021.09.19 15:27:55.090	ErrorCopyTicks (CustomBR,H1)	2021.01.29 00:02:14:782 - first tick, 2021.01.29 23:49:01:540 - last tick
2021.09.19 15:27:55.090	ErrorCopyTicks (CustomBR,H1)	---------------------
2021.09.19 15:27:55.090	ErrorCopyTicks (CustomBR,H1)	---------Err_CopyTicks()------------
2021.09.19 15:27:55.091	ErrorCopyTicks (CustomBR,H1)	CopyTicks('SILV-12.21',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 100 );  received 100 ticks
2021.09.19 15:27:55.091	ErrorCopyTicks (CustomBR,H1)	2021.01.29 00:02:14:782 - first tick, 2021.01.29 11:02:44:891 - last tick
2021.09.19 15:27:55.091	ErrorCopyTicks (CustomBR,H1)	---------------------
2021.09.19 15:27:55.091	ErrorCopyTicks (CustomBR,H1)	---------Err_CopyTicks()------------
2021.09.19 15:27:55.170	ErrorCopyTicks (CustomBR,H1)	CopyTicks('SILV-12.21',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 1000000 );  received 763140 ticks
2021.09.19 15:27:55.170	ErrorCopyTicks (CustomBR,H1)	2021.01.29 00:02:14:782 - first tick, 2021.09.17 23:58:41:031 - last tick
2021.09.19 15:27:55.170	ErrorCopyTicks (CustomBR,H1)	---------------------
2021.09.19 15:27:55.170	ErrorCopyTicks (CustomBR,H1)	---------Err_SymbolInfoTick1('CustomBR')------------
2021.09.19 15:27:55.178	ErrorCopyTicks (CustomBR,H1)	CopyTicksRange('SILV-12.21',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 42793 ticks
2021.09.19 15:27:55.178	ErrorCopyTicks (CustomBR,H1)	2021.09.17 00:03:04:576 - first tick, 2021.09.17 19:59:32:398 - last tick
2021.09.19 15:27:55.190	ErrorCopyTicks (CustomBR,H1)	CustomTicksReplace('CustomBR',2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000, Ticks, 42793  );  replaced 42793 ticks
2021.09.19 15:27:55.190	ErrorCopyTicks (CustomBR,H1)	ret=1, mt.time_msc=1970.01.01 00:00:00:000
2021.09.19 15:27:55.190	ErrorCopyTicks (CustomBR,H1)	---------------------
2021.09.19 15:27:55.190	ErrorCopyTicks (CustomBR,H1)	---------Err_SymbolInfoTick2('CustomBR')------------
2021.09.19 15:27:55.196	ErrorCopyTicks (CustomBR,H1)	CopyTicksRange('SILV-12.21',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 42793 ticks
2021.09.19 15:27:55.196	ErrorCopyTicks (CustomBR,H1)	2021.09.17 00:03:04:576 - first tick, 2021.09.17 19:59:32:398 - last tick
2021.09.19 15:27:55.210	ErrorCopyTicks (CustomBR,H1)	CustomTicksAdd('CustomBR',Ticks, 42793  );  added 42793 ticks
2021.09.19 15:27:55.210	ErrorCopyTicks (CustomBR,H1)	ret=1, mt.time_msc=2021.09.17 19:59:32:398
2021.09.19 15:27:55.210	ErrorCopyTicks (CustomBR,H1)	--------------------- 

 
fxsaber #:

К сожалению, нет доступа к этим символам, чтобы воспроизвести.


Sul forex, gli stessi errori. Broker Alpari, conto di prova. Simbolo EURUSD


Simbolo personalizzato fatto sulla base di EURUSD, appena lasciato il nome troppo


2021.09.19 15:36:52.417 tester (EURUSD,H1)      ---------Err_CopyTicksRange()------------
2021.09.19 15:36:52.432 tester (EURUSD,H1)      CopyTicksRange('EURUSD',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 2021.01.31 23:59:00:000 );  received 102934 ticks
2021.09.19 15:36:52.432 tester (EURUSD,H1)      2021.01.29 00:00:00:139 - first tick, 2021.01.29 23:54:59:930 - last tick
2021.09.19 15:36:52.432 tester (EURUSD,H1)      ---------------------
2021.09.19 15:36:52.432 tester (EURUSD,H1)      ---------Err_CopyTicks()------------
2021.09.19 15:36:52.445 tester (EURUSD,H1)      CopyTicks('EURUSD',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 100 );  received 100 ticks
2021.09.19 15:36:52.445 tester (EURUSD,H1)      2021.01.29 00:00:00:139 - first tick, 2021.01.29 00:12:52:513 - last tick
2021.09.19 15:36:52.445 tester (EURUSD,H1)      ---------------------
2021.09.19 15:36:52.445 tester (EURUSD,H1)      ---------Err_CopyTicks()------------
2021.09.19 15:36:52.577 tester (EURUSD,H1)      CopyTicks('EURUSD',Ticks,COPY_TICKS_ALL, 2021.01.29 23:57:00:000, 1000000 );  received 1000000 ticks
2021.09.19 15:36:52.577 tester (EURUSD,H1)      2021.01.29 00:00:00:139 - first tick, 2021.02.15 18:31:34:723 - last tick
2021.09.19 15:36:52.577 tester (EURUSD,H1)      ---------------------
2021.09.19 15:36:52.577 tester (EURUSD,H1)      ---------Err_SymbolInfoTick1('CustomBR')------------
2021.09.19 15:36:52.579 tester (EURUSD,H1)      CopyTicksRange('EURUSD',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 78831 ticks
2021.09.19 15:36:52.579 tester (EURUSD,H1)      2021.09.17 00:00:00:349 - first tick, 2021.09.17 19:59:59:088 - last tick
2021.09.19 15:36:52.645 tester (EURUSD,H1)      CustomTicksReplace('CustomBR',2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000, Ticks, 78831  );  replaced 78831 ticks
2021.09.19 15:36:52.645 tester (EURUSD,H1)      ret=1, mt.time_msc=1970.01.01 00:00:00:000
2021.09.19 15:36:52.645 tester (EURUSD,H1)      ---------------------
2021.09.19 15:36:52.645 tester (EURUSD,H1)      ---------Err_SymbolInfoTick2('CustomBR')------------
2021.09.19 15:36:52.658 tester (EURUSD,H1)      CopyTicksRange('EURUSD',Ticks,COPY_TICKS_ALL, 2021.09.17 00:00:00:000, 2021.09.17 20:00:00:000 );  received 78831 ticks
2021.09.19 15:36:52.658 tester (EURUSD,H1)      2021.09.17 00:00:00:349 - first tick, 2021.09.17 19:59:59:088 - last tick
2021.09.19 15:36:52.686 tester (EURUSD,H1)      CustomTicksAdd('CustomBR',Ticks, 78831  );  added 78831 ticks
2021.09.19 15:36:52.686 tester (EURUSD,H1)      ret=1, mt.time_msc=2021.09.17 19:59:59:088
Motivazione: