Issue with MTTESTER and indicator on foreign symbol in same EA

 

Hello, I have an issue when calling MTTESTER instance from an Expert Advisor with an indicator attached to a foreign symbol.

I discovered this issue when using iSpy but I tried with other indicators and get the same results.

For the first day of the tester time interval, all ticks of the main symbol are received twice but only when the cache of the tester does not exist yet for this interval.

Once the cache exist, the problem disappears.

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//+------------------------------------------------------------------+
#define PROFILER_OnTick
#include <TesterBenchmark.mqh>
#include <MultiTester\MTTester.mqh>

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   string settings;
   MTTESTER::GetSettings(settings);
   
   iCustom("GBPUSD",0,"iSpy",ChartID(),0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick(void)
  {
  }
//+------------------------------------------------------------------+

This code can be launched on EURUSD for instance.

As a result I get:

Test (EURUSD,M1)	2019.07.01 23:59:58   Interval = 0.040 s. (Profiler: Count = 141606, Interval = 0.004 s., 39020666.9 unit/sec)

Whereas when the cache already exists, I get:

Test (EURUSD,M1)	2019.07.01 23:59:58   Interval = 0.031 s. (Profiler: Count = 70803, Interval = 0.002 s., 37761600.0 unit/sec)
EURUSD - Euro vs US Dollar - Today's currency exchange rates — Forex exchange rates
EURUSD - Euro vs US Dollar - Today's currency exchange rates — Forex exchange rates
  • 2024.07.03
  • www.mql5.com
EURUSD - Euro vs US Dollar - Most popular currency pair charts. Use the filter below to select the exchange rates you need. Each chart features Bid/Ask prices, as well as daily growth.
 
I don't see any problems.
 
You mean you could not reproduce the fact that when calling MTTESTER instance the ticks of the main symbol are processed twice for the first day when the cache does not exist yet?
 
olmallet81 #:
You mean you could not reproduce the fact that when calling MTTESTER instance the ticks of the main symbol are processed twice for the first day when the cache does not exist yet?

Write a short playback instruction. What's wrong with working?

 

So, if you launch this expert Test.mq5 on EURUSD you must make sure the tester cache does not exist for the testing time interval, let's say 2019.07.01 to 2019.07.02 as I used, for both EURUSD and GBPUSD ticks and history.

Run the code of Test.mq5 with the lines calling MTTESTER instance commented as below:

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//+------------------------------------------------------------------+
#define PROFILER_OnTick
#include <TesterBenchmark.mqh>
#include <MultiTester\MTTester.mqh>

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //string settings;
   //MTTESTER::GetSettings(settings);
   
   iCustom("GBPUSD",0,"iSpy",ChartID(),0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick(void)
  {
  }
//+------------------------------------------------------------------+

You will get a tick count returned by the profiler of let's say X ticks.

Then on the second run, start by cleaning the cache of the tester for EURUSD and GBPUSD ticks and history, uncomment the lines calling MTTESTER in OnInit().

Then re-launch this expert, on my side the tick count returned by the profile if then 2*X. Each EURUSD tick has been processed twice by the expert.

I verified this behaviour by counting the ticks in OnTick() and got the same results so the issue is not coming from your TesterBenchmark header code.

It seems to happen only for the first day of the time interval, for instance when running this expert from 2019.07.01 to 2019.08.01 it will happen only until 2019.07.02.

This behaviour does not happen if the cache already exist.

 
EURUSD,M1: 95858 ticks, 1440 bars generated. Environment synchronized in 0:00:00.020. Test passed in 0:00:00.420 (including ticks preprocessing 0:00:00.031).
EURUSD,M1: total time from login to stop testing 0:00:00.440 (including 0:00:00.022 for history data synchronization)
163311 total ticks for all symbols
EURUSD: generate 47929 ticks in 0:00:00.015, passed to tester 47930 ticks
GBPUSD: generate 67453 ticks in 0:00:00.016, passed to tester 67454 ticks

x2.

 
 
fxsaber #:
Bug-report.
Thank you