MetaTrader 5 Strategy Tester: bugs, bugs, suggestions for improvement - page 7

 
fxsaber:

A single pass needs to know its input parameters. It is unlikely that such functionality will be introduced, so any thoughts on how this could be done? WinAPI would be fine.

Get the latest MT5 Tester settings.

#include <WinAPI\fileapi.mqh>
#include <WinAPI\handleapi.mqh>

// Получает имя файла настроек последнего запуска MT5-Тестера.
string GetTesterINIFileName( ulong &Size )
{
  string Str = NULL;
  const string Path = ::TerminalInfoString(TERMINAL_PATH)+ "\\MQL5\\Profiles\\Tester\\";
  
  FIND_DATAW FindData;
  const HANDLE handle = kernel32::FindFirstFileW(Path + "*.ini", FindData);
  
  if (handle != INVALID_HANDLE)
  {     
    ulong MaxTime = 0;
    Size = 0;
    
    do
    {
      const ulong TempTime = ((ulong)FindData.ftLastWriteTime.dwHighDateTime << 32) + FindData.ftLastWriteTime.dwLowDateTime;
      
      if (TempTime > MaxTime)
      {
        MaxTime = TempTime;
        
        Str = ::ShortArrayToString(FindData.cFileName);
        Size = ((ulong)FindData.nFileSizeHigh << 32) + FindData.nFileSizeLow;;
      }      
    }
    while (kernel32::FindNextFileW(handle, FindData));    
    
    kernel32::FindClose(handle);
  }
  
  return((Str == NULL) ? NULL : Path + Str);   
}

#define  GENERIC_READ  0x80000000
#define  SHARE_READ    1
#define  OPEN_EXISTING 3

// Получает настройки последнего запуска MT5-Тестера.
string GetTesterINI( void )
{
  string Str = NULL;
  
  ulong Size;
  const string FileName = GetTesterINIFileName(Size);
  
  if (FileName != NULL)
  {
    const HANDLE handle = kernel32::CreateFileW(FileName, GENERIC_READ, SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    
    if (handle != INVALID_HANDLE)
    {
      uint Read;
      ushort Buffer[];
      
      ::ArrayResize(Buffer, (int)Size / sizeof(ushort));
            
      if (kernel32::ReadFile(handle, Buffer, (int)Size, Read, 0))      
        Str = ::ShortArrayToString(Buffer);
      
      kernel32::CloseHandle(handle);        
    }
  }
  
  return(Str);
}


Applying

// Советник при запуске одиночного прогона возвращает свои настройки.
input int inInput1 = 1;
input int inInput2 = 2;

int OnInit()
{
  if (MQLInfoInteger(MQL_TESTER) && !MQLInfoInteger(MQL_OPTIMIZATION))
    Print(GetTesterINI());
  
  return(INIT_FAILED);
}


Result

2019.04.01 00:00:00   ;Одиночный тест советника: Test9, EURUSD M1, цены открытия, 2019.04.01 - 2019.09.18
2019.04.01 00:00:00   [Tester]
2019.04.01 00:00:00   Expert=Test9.ex5
2019.04.01 00:00:00   Symbol=EURUSD
2019.04.01 00:00:00   Period=M1
2019.04.01 00:00:00   Optimization=0
2019.04.01 00:00:00   Model=2
2019.04.01 00:00:00   FromDate=2019.04.01
2019.04.01 00:00:00   ToDate=2019.09.18
2019.04.01 00:00:00   ForwardMode=0
2019.04.01 00:00:00   Deposit=10000
2019.04.01 00:00:00   Currency=EUR
2019.04.01 00:00:00   ProfitInPips=1
2019.04.01 00:00:00   Leverage=100
2019.04.01 00:00:00   ExecutionMode=0
2019.04.01 00:00:00   OptimizationCriterion=6
2019.04.01 00:00:00   Visual=0
2019.04.01 00:00:00   [TesterInputs]
2019.04.01 00:00:00   inInput1=123||1||1||10||N
2019.04.01 00:00:00   inInput2=2||2||1||20||N
 

Forum on trading, automated trading systems and testing trading strategies

New version of MetaTrader 5 build 1640 platform: creating and testing your own financial instruments

fxsaber, 2017.08.04 19:55

During Optimization, is it possible to make some kind of protection (at least in the form of a warning with an audible signal) against taking the computer to Sleep?

Completely forgot that Optimisation was in progress, and closed the laptop lid... The connection was broken, after waking up it was restored and Optimisation went on. But I wouldn't close the lid if I was reminded that Optimisation was in progress. What to say when using the Cloud...

Also, during Optimization, the only indication that Optimization is in progress in the Terminal when the Tester is hidden is a green bar on the icon (as when downloading files in a browser). There is no warning when closing the Terminal that Optimisation is in progress.

 

Replay problem with bool input parameters being displayed in the Tester.

This Expert Advisor

input int i = 0;
input bool b = false;

double OnTester() { return(i); }


Optimize it as shown on the screenshot.


We choose to run one of the passes.


In Parameters we see zero instead of false.


 

Not sure how to reproduce. Sometimes when running a single run from Optimisation results, the log shows (and substitutes) the input parameter values correctly (as in cache, including non-optimised inputs). But at the same time in the Parameters tab some input parameters are not updated.


It turns out that you run Single from Optimize - fine (matches Optimize result).

Then enter Single mode and run the same run via Start button - you get different values (because some inputs have different values than in previous step).

 

It has already been said about the wild size of the logs. When you look at the log, 99% of the time you are interested in the beginning and the end of the log. So because of the wild size, the beginning can't be seen at all.

How about duplicating the beginning and end of the log? In particular, to see at what input parameters was the start.

 
Got into a situation where it was impossible to see the results of previous optimisations. The only thing that helped was a reboot.
 

These are the messages the tester now gives out.

 
fxsaber:

This is the message the tester is now giving out.

The tester has given these messages before. Since it is now possible to download opt-files. This is a warning that ifoptimization is run, this opt-file will be overwritten and optimization will start again

 
Slava:

in the event of an optimisation run, this opt-file will be overwritten

Will the name match?