how to use the function:double TesterStatistics(ENUM_STATISTICS statistics_value)? - page 2

 

och:

I even add a counter passcount is a global variable but is not increasing.

Using static variables on global scope won't help you during an optimization. Every time when new backtesting pass starts all global variables initialize. Finishing a pass means death of all variables.

See Visibility Scope and Lifetime of Variables:

A variable declared outside all functions is located into the global scope. Access to such variables can be done from anywhere in the program.These variables are located in the global pool of memory, so their lifetime coincides with the lifetime of the program.


 
Rosh:

Using static variables on global scope won't help you during an optimization. Every time when new backtesting pass starts all global variables initialize. Finishing a pass means death of all variables.

See Visibility Scope and Lifetime of Variables:


Thanks a lot Rosh, 

Now it works. I completly forgot FileSeek. The issue now is that file is spread in as many Agent directory as I am running agent. Is it possible that all Agents write in the same file? 

Regards,

Olivier 

 

och:

The issue now is that file is spread in as many Agent directory as I am running agent. Is it possible that all Agents write in the same file? 

We are going to translate the article Основы тестирования в MetaTrader 5 into English, where you can find the answer on this question. At the moment you can use Google Translate service to read how to do it:

Using a shared folder for all client terminals

All testernye agents are isolated from each other and from the client terminal: each agent has its own folder in which the written logs of the agent. In addition, all file operations with test agent originate in the folder imya_agenta/MQL5/Files.  However, we can realize the interaction between local agents and the client terminal through a common folder for all client terminals, if you open a file to specify the flag FILE_COMMON :

//+-----------------------------------------------
//| Expert initialization function               |
//+-----------------------------------------------
int OnInit ()
  { 
//--- Public folder for all client terminals
 common_folder = TerminalInfoString (TERMINAL_COMMONDATA_PATH);
//--- Displays the name of the folder
 PrintFormat ("Open the file in a shared folder client terminals% s", common_folder);
//--- Open the file in a shared folder (the flag FILE_COMMON)
 handle = FileOpen (filename, FILE_WRITE | FILE_READ | FILE_COMMON);
   ... futher actions
//---
return (0);
  } 


Reason: