MT5 Strategy Tester - Problem with function SymbolInfoTick() in real tick mode. Need help!

 

Hi everybody,

I'm using MT5 build 1510 with a MetaQuotes-Demo Account (Hedge). The server is MetaQuotes-Demo Server.

Here a simple EA copied and slightly modified from MQL5 Reference / Standard Constants, Enumerations and Structures / Data Structures / Price Data Structure:

 

int g_fp;
int g_nticks;
int OnInit() {
  g_nticks = 0;
  g_fp = FileOpen ("TickTests.txt", FILE_TXT|FILE_WRITE);
  return INIT_SUCCEEDED;
}

void OnDeinit(const int reason) {
  FileWrite (g_fp, "nticks = ", g_nticks);
  FileClose (g_fp);
}

void OnTick() {
  MqlTick last_tick;
  g_nticks++;
  if(SymbolInfoTick(Symbol(),last_tick)) {
    FileWrite (g_fp, last_tick.time,": Bid = ",last_tick.bid,
               " Ask = ",last_tick.ask,"  Volume = ",last_tick.volume);
  } else {
    FileWrite (g_fp, "SymbolInfoTick() failed, error = ",GetLastError());
  }
  if (g_nticks == 100) {
    ExpertRemove();
  }
}

 

 Now I start the strategy tester: EURUSD Daily, Date 2017.01.09 - 2017.01.20 in 'Every tick' mode. And - as I expected - I have no problems, here the first ten lines of the output file:

2017.01.09 00:00:59: Bid = 1.05292 Ask = 1.05324  Volume = 1500000
2017.01.09 00:01:00: Bid = 1.05292 Ask = 1.05324  Volume = 1458333
2017.01.09 00:01:08: Bid = 1.05247 Ask = 1.05279  Volume = 1458333
2017.01.09 00:01:17: Bid = 1.05248 Ask = 1.0528  Volume = 1458333
2017.01.09 00:01:25: Bid = 1.05203 Ask = 1.05235  Volume = 1458333
2017.01.09 00:01:34: Bid = 1.05241 Ask = 1.05273  Volume = 1458333
2017.01.09 00:01:59: Bid = 1.0528 Ask = 1.05312  Volume = 1458335
2017.01.09 00:02:00: Bid = 1.0528 Ask = 1.05312  Volume = 1400000
2017.01.09 00:02:12: Bid = 1.05287 Ask = 1.05319  Volume = 1400000
2017.01.09 00:02:24: Bid = 1.05295 Ask = 1.05327  Volume = 1400000


But if I switch to the mode 'Every tick based on real ticks', I run into some problems. Please see the first lines of the output file:

2017.01.09 00:00:40: Bid = 0 Ask = 0  Volume = 750000
2017.01.09 00:00:55: Bid = 0 Ask = 0  Volume = 750000
2017.01.09 00:01:01: Bid = 0 Ask = 0  Volume = 500000
2017.01.09 00:01:01: Bid = 0 Ask = 0  Volume = 250000
2017.01.09 00:01:02: Bid = 0 Ask = 0  Volume = 2000000
2017.01.09 00:01:22: Bid = 0 Ask = 0  Volume = 2000000
2017.01.09 00:01:45: Bid = 0 Ask = 0  Volume = 2000000
2017.01.09 00:01:49: Bid = 0 Ask = 0  Volume = 2000000
2017.01.09 00:02:02: Bid = 0 Ask = 0  Volume = 3000000
2017.01.09 00:02:45: Bid = 0 Ask = 0  Volume = 600000
2017.01.09 00:02:51: Bid = 1.05294 Ask = 1.05331  Volume = 600000
2017.01.09 00:02:57: Bid = 1.05294 Ask = 1.05331  Volume = 1000000
2017.01.09 00:02:57: Bid = 1.05295 Ask = 1.0533  Volume = 1000000
2017.01.09 00:02:58: Bid = 1.05295 Ask = 1.0533  Volume = 1000000
2017.01.09 00:02:58: Bid = 1.05294 Ask = 1.05329  Volume = 1000000


 The first ten ticks have wrong bid and ask values and I have no idea what is wrong here???

 The Journal text is the following:

2017.01.23 22:10:39.858 Tester  EURUSD: ticks data begins from 2011.12.19 00:00
2017.01.23 22:10:39.858 Core 1  connecting to 127.0.0.1:3000
2017.01.23 22:10:39.858 Core 1  connected
2017.01.23 22:10:39.860 Core 1  authorized (agent build 1510)
2017.01.23 22:10:39.863 Tester  EURUSD,Daily (MetaQuotes-Demo): testing of Experts\TickTest.ex5 from 2017.01.09 00:00 to 2017.01.20 00:00
2017.01.23 22:10:39.868 Core 1  common synchronization completed
2017.01.23 22:10:39.902 Core 1  EURUSD: ticks synchronized already [43 bytes]
2017.01.23 22:10:40.509 Core 1  login (build 1510)
2017.01.23 22:10:40.509 Core 1  account info found
2017.01.23 22:10:40.509 Core 1  1482 bytes of tester parameters loaded
2017.01.23 22:10:40.509 Core 1  188 bytes of input parameters loaded
2017.01.23 22:10:40.509 Core 1  expert file added: Experts\TickTest.ex5. 7600 bytes loaded
2017.01.23 22:10:40.509 Core 1  initial deposit 10000.00 USD, leverage 1:500
2017.01.23 22:10:40.509 Core 1  successfully initialized
2017.01.23 22:10:40.509 Core 1  9398 bytes of total initialization data received
2017.01.23 22:10:40.509 Core 1  Intel Core i7-2600  @ 3.40GHz, 8174 MB
2017.01.23 22:10:40.509 Core 1  EURUSD: load 27 bytes of history data to synchronize in 0:00:00.000
2017.01.23 22:10:40.509 Core 1  EURUSD: history synchronized from 2002.01.01 to 2017.01.20
2017.01.23 22:10:40.509 Core 1  EURUSD: ticks synchronization started
2017.01.23 22:10:40.509 Core 1  EURUSD: load 34 bytes of tick data to synchronize in 0:00:00.000
2017.01.23 22:10:40.509 Core 1  EURUSD: history ticks synchronized from 2011.12.19 to 2017.01.19
2017.01.23 22:10:40.509 Core 1  EURUSD,Daily: history cache allocated for 275 bars and contains 265 bars from 2016.01.04 00:00 to 2017.01.06 00:00
2017.01.23 22:10:40.509 Core 1  EURUSD,Daily: history begins from 2016.01.04 00:00
2017.01.23 22:10:40.509 Core 1  EURUSD,Daily (MetaQuotes-Demo): generating based on real ticks
2017.01.23 22:10:40.509 Core 1  EURUSD,Daily: testing of Experts\TickTest.ex5 from 2017.01.09 00:00 to 2017.01.20 00:00 started
2017.01.23 22:10:40.509 Core 1  EURUSD : real ticks begin from 2011.12.19 00:00:00
2017.01.23 22:10:40.509 Core 1  2017.01.09 00:07:07   ExpertRemove() function called
2017.01.23 22:10:40.509 Core 1  removed itself within OnTick
2017.01.23 22:10:40.509 Core 1  final balance 10000.00 USD
2017.01.23 22:10:40.509 Core 1  removed itself on 0% of testing interval
2017.01.23 22:10:40.509 Core 1  EURUSD,Daily: 100 ticks, 1 bars generated. Test passed in 0:00:00.624 (including ticks preprocessing 0:00:00.312).
2017.01.23 22:10:40.509 Core 1  349 Mb memory used including 0.47 Mb of history data, 128 Mb of tick data
2017.01.23 22:10:40.509 Core 1  log file "C:\Users\Matthias\AppData\Roaming\MetaQuotes\Tester\D0E8209F77C8CF37AD8BF550E51FF075\Agent-127.0.0.1-3000\logs\20170123.log" written
2017.01.23 22:10:40.524 Core 1  connection closed

 

This behaviour is reproducible, and I get a similar behaviour for different start and end dates as well.

Who can help me, I'm desperate :-( 

 Thanks in advance

 

Matthias / Bobcat

 
First of all you should try with a non beta version. Build 1495. If it's the same please tell us.
 
Alain Verleyen:
First of all you should try with a non beta version. Build 1495. If it's the same please tell us.
You should also try with a real broker, I am not sure Metaquotes-Demo is providing reliable data.
 
Alain Verleyen:
You should also try with a real broker, I am not sure Metaquotes-Demo is providing reliable data.

Hello Alain,

thanks for your quick answer.

You are right: in the meantime I tried it on a demo account of a real broker with MT5 build 1495 and all problems disappear!!


 Matthias / Bobcat

 
Dr Matthias Hammelsbeck:

Hello Alain,

thanks for your quick answer.

You are right: in the meantime I tried it on a demo account of a real broker with MT5 build 1495 and all problems disappear!!


 Matthias / Bobcat

Happy to help.
 
Alain Verleyen:
Happy to help.

Unfortunately I was looking forward to early :-(

I could reproduce the problem with build 1495 (different testing period in dec 2016) and especially with the newest build 1525 (an official release).

I reported this to the service desk and get the answers

We're aware about this problem. Unfortunately, we have no such plans to change it right now. If at the beggining of testing there are ticks with last price instead of Bids and Asks, so there is no way to get these last bids and asks.

 and

it depends on ticks

and

If you start client termial first time, you can get zero bid and ask in the real life

I think we have to live with this problem, or?
I'm not amused.

Any ideas?

Matthias / Bobcat


 

 
Ideas about what ?
 
Alain Verleyen:
Ideas about what ?

How to deal with this problem. May be a small isuue appearing only in the real tick mode of strategy tester at the very beginning of the test (I hope).

Workaround: waiting for the first tick with correct bid and ask values in testing mode

 
Dr Matthias Hammelsbeck:

How to deal with this problem. May be a small isuue appearing only in the real tick mode of strategy tester at the very beginning of the test (I hope).

Workaround: waiting for the first tick with correct bid and ask values in testing mode

Seems obvious.
Reason: