Testing 'CopyTicks' - page 39

 
 
fxsaber:

They should not be slow and dependent on the trading server.

Delivery speed: terminal stores 4096 last ticks for each symbol in cache for quick access (for symbols with running statistic - 65536 ticks), requests to this data are faster. When requesting ticks of the current trading session outside of the cache, CopyTicks() accesses ticks already stored in the terminal's memory, these requests take more time to execute. The slowest are requests of ticks for other days, because in this case the data is read from the disk.

If the terminals are on the same disk, you are right.

Have you performed several tests? Are you constantly experiencing delays on a certain server? Just in case the disk was busy with some other operation at the moment of test...

 
Alexey Kozitsyn:

If the terminals are on the same drive, you are right.

Have you run multiple tests? Is the latency constantly on a particular server? Just in case the drive was busy with some other operation at the time of the test...

It's 100% reproducible. The terminal is the same.

 

How to get ticks in OnDeinit indicator? I want to get ticks, which already exist in tkc-files and which are given almost instantly. But how to determine which ticks are there and which are not?

Behind all the apparent attractiveness of the simplicity of CopyTicks, there are actually hidden pitfalls, which are impossible to avoid because of the limited functionality for the sake of this outer appeal again.

 
fxsaber:

How to get ticks in OnDeinit indicator? I want to get ticks, which already exist in tkc-files and which are given almost instantly. But how to determine which ticks are there and which are not?

Behind all the apparent attractiveness of the simplicity of CopyTicks, there are actually hidden pitfalls, which are impossible to avoid because of the limited functionality for the sake of this outer appeal again.

Why should we get the ticks in OnDeinit()?
 
Alexey Kozitsyn:
Why to get ticks in OnDeinit()?

You need to create a custom symbol and write to it all the converted tick history (from a certain date) that already exists in the tkc files. The ticks, which are not on the machine, are not interesting. Therefore, the indicator shouldn't slow down at this task. However, CopyTicks doesn't allow to receive ticks in such way.

 
Trying to get ticks on another symbol in OnInit
#include <Trade\Trade.mqh>

bool OpenPos( const string Symb )
{
  static CTrade Trade;
  
  return(Trade.Buy(1, Symb));
}

void OnInit()
{
  Sleep(3600 * 1000);    
  
  OpenPos("NZDUSD"); // Заставляем Агент получить тики по чужому символу

  MqlTick Ticks[];
  
  Print(CopyTicks("NZDUSD", Ticks, COPY_TICKS_INFO, 0, 5)); // 0
  
  ArrayPrint(Ticks);
}


Result

MetaTester 5 started on 127.0.0.1:3000
initialization finished
login (build 1653)
template file tester.tpl added. 2398 bytes loaded
38520 bytes of account info loaded
1482 bytes of tester parameters loaded
188 bytes of input parameters loaded
3456 bytes of symbols list loaded
expert file added: Experts\Test4.ex5. 44667 bytes loaded
initial deposit 10000000.00 USD, leverage 1:500
successfully initialized
48 Kb of total initialization data received
Intel Core i7-2700 K  @ 3.50 GHz, 16301 MB
EURUSD: symbol to be synchronized
EURUSD: symbol synchronized, 3464 bytes of symbol info received
EURUSD: history synchronization started
EURUSD: load 27 bytes of history data to synchronize in 0:00:00.000
EURUSD: history synchronized from 2016.01.04 to 2017.10.11
EURUSD: ticks synchronization started
EURUSD: load 34 bytes of tick data to synchronize in 0:00:00.000
EURUSD: history ticks synchronized from 2017.04.03 to 2017.10.10
EURUSD,M1: history cache allocated for 667542 bars and contains 651824 bars from 2016.01.04 00:00 to 2017.09.29 23:59
EURUSD,M1: history begins from 2016.01.04 00:00
EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
EURUSD,M1: testing of Experts\Test4.ex5 from 2017.10.01 00:00 to 2017.10.11 00:00 started
EURUSD : real ticks begin from 2017.04.03 00:00:00
EURUSD : 2017.10.01 00:00 - 2017.10.11 00:00  last prices absent for 7 whole days, bars built by bid prices
NZDUSD: symbol to be synchronized
NZDUSD: symbol synchronized, 3464 bytes of symbol info received
NZDUSD: history synchronization started
NZDUSD: load 27 bytes of history data to synchronize in 0:00:00.000
NZDUSD: history synchronized from 2016.01.04 to 2017.10.11
NZDUSD: ticks synchronization started
NZDUSD: load 34 bytes of tick data to synchronize in 0:00:00.000
NZDUSD: history ticks synchronized from 2017.10.02 to 2017.10.10
2017.10.01 01:00:00   instant buy 1.00 NZDUSD at 0.72043 (0.72017 / 0.72043)
2017.10.01 01:00:00   deal #2 buy 1.00 NZDUSD at 0.72043 done (based on order #2)
2017.10.01 01:00:00   deal performed [#2 buy 1.00 NZDUSD at 0.72043]
2017.10.01 01:00:00   order performed buy 1.00 at 0.72043 [#2 buy 1.00 NZDUSD at 0.72043]
2017.10.01 01:00:00   CTrade::OrderSend: instant buy 1.00 NZDUSD at 0.72043 [done at 0.72043]
2017.10.01 01:00:00   true
2017.10.01 01:00:00   0
NZDUSD : real ticks begin from 2017.10.02 00:00:00
NZDUSD : 2017.10.01 00:00 - 2017.10.11 00:00  last prices absent for 7 whole days, bars built by bid prices


I.e. there is no tick data at the beginning on someone else's character. And the ticks are generated in the database as OnTick appears. Is it designed that way or ticks for the alien characters should be available, as well as for the main test symbol?

 
What does this quote from the Documentation mean?

Примечание

The CopyTicksRange() function is designed to request ticks from a strictly specified range, for example, for a particular day in the history. While CopyTicks()allows tospecify only the starting date, for example - to get all ticks from the beginning of the month to the current moment.

Документация по MQL5: Доступ к таймсериям и индикаторам / CopyTicksRange
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyTicksRange
  • www.mql5.com
[out]  Cтатический или динамический массив MqlTick для приема тиков. Если в статический массив не вмещаются все тики из запрошенного интервала времени, то будет получено столько тиков, сколько помещается в массив. При этом функция сгенерирует ошибку ERR_HISTORY_SMALL_BUFFER (4407) . ERR_NOT_ENOUGH_MEMORY – не хватает памяти для получения...
 

CopyTicks only works with characters that are included in the Market Review. And this was always logical before the advent of custom symbols.

Custom symbols have a huge field of application and it is far from always that these symbols are required in the Market Watch. However, getting some of the tick history out of them via CopyTicks is sometimes necessary.

Therefore, please disable the CopyTicks error return for custom symbols if the custom one is not selected in Market Watch.

 
For custom characters, to find out the total number of ticks, you have to use CopyTicksRange(Symb, Ticks) ( plus this) and watch the size of the array. But this is very wasteful!
Reason: