Libraries: MultiTester - page 45

 

Forum on trading, automated trading systems and testing trading strategies

New version of MetaTrader 5 build 3081: Improvements in MQL5 services and updated design

fxsaber, 2021.10.15 12:33 pm

The script shows an incomprehensible limitation on the length of file names that are created without problems in the file manager.

void CheckFile( string FileName )
{
  uchar Bytes[1];  
  
  FileName = "TempFolder\\" + FileName + "\\" + FileName + "\\" + FileName;
  Print(StringLen(FileName)); // 313

  Print(FileSave(FileName, Bytes)); //false
  Print(_LastError); // ERR_TOO_LONG_FILENAME (5003)
}

void OnStart()
{
  CheckFile("ExpertNameExpertName.EURUSDEURUSDEURUSD.M1.20210701.20211009.41.BAA0EE191CCD66EB8291EC4D6434A6C8.opt");
}

Please solve the length of the file name. In practice you should use here.


The following functions allow to work with long paths (more than MAX_PATH).

MTTESTER::FileSave
MTTESTER::FileLoad
MTTESTER::FileCopy
MTTESTER::FileMove
MTTESTER::FileIsExist


The example above will work if you replace the standard function.

Print(MTTESTER::FileSave(TerminalInfoString(TERMINAL_DATA_PATH) + "\\MQL5\\Files\\" + FileName, Bytes)); //true


Also added a function to get a list of files by mask, including subfolders (similar to this one).

#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

void OnStart()
{
  string FileNames[];
  
  // Get all log files in the terminal folder. Supports long paths (> MAX_PATH).
  MTTESTER::GetFileNames(FileNames, TerminalInfoString(TERMINAL_DATA_PATH) + "\\*.log");

  ArrayPrint(FileNames);
}


I often encountered limitations on file path length in standard functions. Judging by the implementation, possible addition of support for files with long paths to standard functions looks simple from MQ side.

 
When debugging code, I often use clearing logs before active prints to avoid confusion with the previous session.
#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

void OnStart()
{
  MTTESTER::TerminalJournalClear(); // Cleansing the Journal of Experts.
  
  Print("First Print.");
}
 

Added additional information to the file names and their contents. Otherwise it was difficult to understand when and what was launched (I do a lot of automatic calculations).

// Generated by bool MTTESTER::CheckInputs(const bool): https://www.mql5.com/ru/code/26132
// Link: https://www.mql5.com/ru/blogs/post/760770

// [Tester].
// Expert=HelloWorld.ex5
// Symbol=EURUSD
// Period=M1
// FromDate=2024.11.04.
// Deposit=10000.0
// Currency=EUR
// Leverage=500
// ServerName=MetaQuotes-Demo
// [TesterInputs]

inRange1=3
; GroupName
inRange2=3



Now you can copy these data to the clipboard (CTRL+C) and transfer them to the Settings tab (CTRL+V) of the Tester. After that run a single pass of the alarm combination.

 
fxsaber #:
When debugging code, I often use log clearing before active prints to avoid confusion with the previous session.

The function is called TerminalJournalClear, but it does not clear the log, only the Expert tab does.

 
Andrei Iakovlev #:

The function is called TerminalJournalClear, but it does not clear the journal, only the Expert tab does.

Is there a terminological difficulty? Clearing the Experts tab - there are scripts. The logs tab - I haven't thought of it.

 
Hi, can anyone confirm if the MTTester.mqh library has become obsolete with new new 5100 build push June 6, 2025 ?
 
Muhammad Fahad #:
Hi, can anyone confirm if the MTTester.mqh library has become obsolete with new new 5100 build push June 6, 2025 ?
'MTTester.mqh'
WinAPI.mqh                      
windef.mqh                      
winnt.mqh                       
fileapi.mqh                     
winbase.mqh                     
winuser.mqh                     
wingdi.mqh                      
winreg.mqh                      
handleapi.mqh                   
processthreadsapi.mqh                   
securitybaseapi.mqh                     
errhandlingapi.mqh                      
sysinfoapi.mqh                  
processenv.mqh                  
libloaderapi.mqh                        
memoryapi.mqh                   
0 errors, 0 warnings, 193 msec elapsed, cpu='X64 Regular'
 

Forum on trading, automated trading systems and testing trading strategies

Libraries: MultiTester

fxsaber, 2022.09.01 10:26 AM

Terminal LiveUpdate management.
// Switching the terminal LiveUpdate state.

#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

void OnStart()
{
  const bool IsLiveUpdate = MTTESTER::IsTerminalLiveUpdate();
                     
  if (MessageBox("Current LiveUpdate - " + (IsLiveUpdate ? "ON" : "OFF") + ".\n\nWant to switch?",
                 "LiveUpdate Status", MB_YESNO) == IDYES)
   MessageBox("Current LiveUpdate - " + ((IsLiveUpdate ? !MTTESTER::TerminalLiveUpdateOFF() : MTTESTER::TerminalLiveUpdateON()) ? "ON." : "OFF."));
}

Service to disallow updates.

#property service

#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

void OnStart()
{
  while (!IsStopped())
  {
    MTTESTER::TerminalLiveUpdateOFF();
    
    Sleep(5000);
  }
}

 
Afternoon. Thank you very much for the library! Could you please tell me how to implement brute-force optimisation criteria?
 
parameter convertion type 'short[260]' to 'ushort[] &' is not allowed	MTTester.mqh	135	39
   int user32::GetClassNameW(long,ushort&[],int)	winuser.mqh	1414	37
'ReadFile' - no one of the overloads can be applied to the function call	MTTester.mqh	1283	21
   in template 'int MTTESTER::FileLoad(const string,T&[])' specified with [T=short]	MTTester.mqh	1270	14
   see template instantiation 'MTTESTER::FileLoad<short>'	MTTester.mqh	1569	23
could be one of 3 function(s)	MTTester.mqh	1283	21
   int kernel32::ReadFile(long,ushort&[],uint,uint&,OVERLAPPED&)	fileapi.mqh	124	8
   int kernel32::ReadFile(long,ushort&[],uint,uint&,long)	fileapi.mqh	125	8
   int kernel32::ReadFile(long,uchar&[],uint,uint&,long)	MTTester.mqh	60	7
2 errors, 0 warnings		2	0
текущий MTTester.mqh не  проходит проверку при компиляции себя же самого в 5100

On 2 different computers on this update - MultiTester

Updated: 2025.06.06 08:04