Tick story - page 16

 
Karputov Vladimir:

Here's what was asked for:

Transition after 24 hours is correct.
Test method: With the terminal on, I erased the tick history files. Then ran the script twice (since there was no history, the first run of the script initialized the history load).

Yes thanks, did the same - helped. However, very strange behaviour.
 

The truth is that the strange behaviour doesn't end there. I decided to compare two query moments of the same story.

The first moment was yesterday when I wrote about the Friday to Monday arrival error:

Forum on trading, automated trading systems and trading strategy testing

Tick story

Tapochun, 2015.10.19 08:48

A little bit later - the picture is like this. ALL 3000 ticks mode:

2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2774 2015.10.16 23:59:05: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54356
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2775 2015.10.16 23:59:05: spread = 72, ask = 1.54428, bid = 1.54356, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2776 2015.10.16 23:59:06: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54356
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2777 2015.10.16 23:59:06: spread = 75, ask = 1.54431, bid = 1.54356, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2778 2015.10.16 23:59:07: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54357
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2779 2015.10.16 23:59:07: spread = 74, ask = 1.54431, bid = 1.54357, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2780 2015.10.16 23:59:10: spread = 0, ask = 0.00000, bid = 0.00000, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2781 2015.10.19 09:44:41: spread = 18, ask = 1.54498, bid = 1.54480, last = 1.54480
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2782 2015.10.19 09:44:41: spread = 19, ask = 1.54499, bid = 1.54480, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2783 2015.10.19 09:44:42: spread = 19, ask = 1.54499, bid = 1.54480, last = 1.54480
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2784 2015.10.19 09:44:42: spread = 18, ask = 1.54498, bid = 1.54480, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2785 2015.10.19 09:44:42: spread = 18, ask = 1.54498, bid = 1.54480, last = 1.54480
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2786 2015.10.19 09:44:42: spread = 19, ask = 1.54499, bid = 1.54480, last = 0.00000
2015.10.19 11:46:33.144 test_CopyTicks_1178 (GBPUSD,M5) OnStart: #2787 2015.10.19 09:44:42: spread = 19, ask = 1.54499, bid = 1.54480, last = 1.54480

Hole in the story. In INFO mode - similar.

Note the ticks coming in at 9.44.41 onwards. Now history for the same symbol, at the same time, in the same mode (ALL) only requested today:

QK      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289463 2015.10.19 09:44:41: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54480
LN      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289464 2015.10.19 09:44:41: spread = 19, ask = 1.54499, bid = 1.54480, last = 0.00000
DO      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289465 2015.10.19 09:44:42: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54480
ES      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289466 2015.10.19 09:44:42: spread = 18, ask = 1.54498, bid = 1.54480, last = 0.00000
HR      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289467 2015.10.19 09:44:42: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54480
EG      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289468 2015.10.19 09:44:42: spread = 19, ask = 1.54499, bid = 1.54480, last = 0.00000
DI      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289469 2015.10.19 09:44:42: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54480
DH      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289470 2015.10.19 09:44:42: spread = 18, ask = 1.54498, bid = 1.54480, last = 0.00000
IM      0       13:04:51.698    test_CopyTicks_1178 (GBPUSD,M5) OnStart: #289471 2015.10.19 09:44:42: spread = 0, ask = 0.00000, bid = 0.00000, last = 1.54480

The delivery method is different. And definitely milliseconds are missing.

And how to analyse ticks in this situation!

 
Renat Fatkhullin:

That's correct.

I have pointed out exactly - there is no structure or logic in filling in the ticks. Each price field is independent of the others. What comes from the supplier is what is translated.

Renat, it turns out that the same ticks can come from a supplier depending on the time of the request and in different ways!

Does the format of history depend on the server you are connected to?

 
Tapochun:

This is promised to be in the next build and I'm sure it will have its chips.

It would be good if without "chips", and normally ... and got tired of these charts that say 99% simulation quality ... and the real one doesn't even come close :) For me, in principle, there shouldn't be such a thing, otherwise it's not a tester but a toy. And you can't make much gruel out of bar closing strategies...

 
Maxim Dmitrievsky:

It would be nice if there were no "tricks" and it was OK... but I'm tired of these charts that say 99% modelling quality... and the real one doesn't even come close :) For me, in principle, there shouldn't be such a thing, otherwise it's not a tester but a toy. And you can't make much gruel out of bar closing strategies...

Without chips, it rarely happens at once. This tick history has been awaited for a long time, and we want to finish it as soon as possible. I want it to be ready both in the tester and on the real account. Unfortunately, there is not much feedback. I hope the work to bring it up to speed is progressing.

 
Karputov Vladimir:

Please specify the COPY_TICKS_INFO tick receiving flag (only Bid and Ask) - can Bid and Ask still be with the value "0" or in COPY_TICKS_INFO mode - Bid and Ask will not contain zeros and the tick flow will be similar to the onein the terminal, in "Market Watch" window, "Ticks" tab?


It will be solved in the build 1200:

MQL5: Extended format of MqlTick structure. Now, it contains the tick arrival time in milliseconds, as well as flags that allow determining which parameter of the tick has changed.
struct MqlTick
  {
   datetime     time;          // Время последнего обновления цен
   double       bid;           // Текущая цена Bid
   double       ask;           // Текущая цена Ask
   double       last;          // Текущая цена последней сделки (Last)
   ulong        volume;        // Объем для текущей цены Last
   long         time_msc;      // Время последнего обновления цен в миллисекундах
   uint         flags;         // Флаги тиков
  };
Each tick always has all parameters filled in, regardless of whether the data have changed since the previous tick. This allows you to always have an up-to-date status of prices at any point in time without having to search through the tick history for previous values. For example, with a tick only the bid price might have changed, but the structure will contain other parameters in addition to the new price: previous ask price, volume, etc. To find out which data exactly have changed with the current tick, analyze its flags:

  • TICK_FLAG_BID - tick changed price bid
  • TICK_FLAG_ASK - tick changed the ask price
  • TICK_FLAG_LAST - tick changed price of last deal
  • TICK_FLAG_VOLUME - Tick has changed volume
  • TICK_FLAG_BUY - Tick occurred as a result of a buy deal
  • TICK_FLAG_SELL - the tick occurred as a result of a sell deal

MqlTick structure is used in two methods:

  • CopyTicks - the method doesn't support the old structure format. Previously compiled EX5 files that use the old tick format will return error 4006 (ERR_MQL_INVALID_ARRAY) when calling the CopyTicks function.
  • SymbolInfoTick - method supports both old and new structure format.
 

So:

MetaTrader 5 x64 build 1192 started (MetaQuotes Software Corp.)
...
authorized on MetaQuotes-Demo through Access Point Asia (ping: 556.27 ms)

and the updated MqlTick structure:

Updated MqlTick structure

 
Karputov Vladimir:

So:

and updated MqlTick structure:


And how to properly track the arrival of a new tick in the terminal? For example, in the tester.

"Function OnTick() is not a handler of each tick, it notifies an Expert Advisor about changes in the market. Changes can be batch: several ticks can come to the terminal simultaneously, but the OnTick() function will be called only once to notify the Expert Advisor of the latest market condition".

 
Maxim Dmitrievsky:

What is the correct way to track the arrival of a new tick in the terminal? For example, in the tester.

"The OnTick() function is not a handler of each tick, it notifies the Expert Advisor about changes in the market. Changes can be batch: the terminal can receive several ticks at the same time, but the OnTick() function will be called only once to inform the Expert Advisor about the latest market condition".

If you want to track every tick, you must do it in the indicator. An indicator, unlike an EA, handles every tick.

Added: now it is possible to analyse all ticks in EA as well - only it is necessary to enter checks (for example to analyse CopyTicks request with depth of 5 ticks).

 

Build 1192. Windows 10 x32.

Preliminarily deleted the tick history folder of MetaQuotes-Demo server completely. Using indicator

//+------------------------------------------------------------------+
//|                                                         test.mq5 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property indicator_chart_window
#property indicator_plots 0
//--- input parameter
input int   InpShowTicks=500;    // клубина истории тиков
//--- parameters
MqlTick     arr_mql_tick[];      // массив структур хранящий тики
bool        bingo=false;         // false - скачано тиков меньше запрошенного
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   Comment("");
   ResetLastError();
//--- новый размер массива структур тиков
   if(ArrayResize(arr_mql_tick,InpShowTicks)==-1)
     {
      Print("Error OnInit #1",GetLastError());
      return(INIT_FAILED);
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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[])
  {
   static int count;
   string text="";
   if(bingo)
      return(rates_total);
   int copied=CopyTicks(_Symbol,arr_mql_tick,COPY_TICKS_INFO,0,InpShowTicks);
   if(copied==InpShowTicks)
      bingo=true;
   text="Запрошено "+IntegerToString(InpShowTicks)+" тиков, скачано "+IntegerToString(copied);
   Comment(text);
   count++;
   return(rates_total);
  }
//+------------------------------------------------------------------+

I have checked ticks downloading. For some instruments 500 ticks are downloaded at the first or second tick and they do not download more than 200 Kb (I simply drag and drop tools from Market Watch on a chart).

But in some instruments miracles happen: the history of ticks doesn't want to give me necessary 500 ticks, but the terminal downloads about 20 Mb of history (history for 10 and 9 months).

Files:
test.mq5  3 kb
Reason: