OnTesterDeinit and OnTesterPass not firing

 

Hi,

I can't seem to get these events to fire. I'm trying to write to a file but it does not output and the Print() function does not output anything to the log either. If I place the same code in OnInit() it works fine and I find the file with the output. I am using a 4 core processor and no local network farm or cloud network testing an EA in OHLC mode. Any ideas what could be wrong? I have looked through the forum and articles and can't seem to find an answer. Many thanks for your help.

Here is my code:

void OnTesterDeinit(void)
{
   Print("HERE OK?"); 
   
    ResetLastError(); 
   int filehandle=FileOpen("output.csv",FILE_WRITE|FILE_CSV); 
   if(filehandle!=INVALID_HANDLE) 
     { 
      FileWrite(filehandle,TimeCurrent(),Symbol(), EnumToString(_Period)); 
      FileClose(filehandle); 
      Print("FileOpen OK"); 
     } 
   else Print("Operation FileOpen failed, error ",GetLastError()); 
}

void OnTesterPass(void)
{
    ResetLastError(); 
   int filehandle=FileOpen("output.csv",FILE_WRITE|FILE_CSV); 
   if(filehandle!=INVALID_HANDLE) 
     { 
      FileWrite(filehandle,TimeCurrent(),Symbol(), EnumToString(_Period)); 
      FileClose(filehandle); 
      Print("FileOpen OK"); 
     } 
   else Print("Operation FileOpen failed, error ",GetLastError()); 
}
 
indigo79:

Hi,

I can't seem to get these events to fire. I'm trying to write to a file but it does not output and the Print() function does not output anything to the log either. If I place the same code in OnInit() it works fine and I find the file with the output. I am using a 4 core processor and no local network farm or cloud network testing an EA in OHLC mode. Any ideas what could be wrong? I have looked through the forum and articles and can't seem to find an answer. Many thanks for your help.

Here is my code:

Do you understand that these events are only generated during an optimization ? And that the are fired to manage Frames ?

Read the documentation please.

 
indigo79:

Hi,

I can't seem to get these events to fire. I'm trying to write to a file but it does not output and the Print() function does not output anything to the log either. If I place the same code in OnInit() it works fine and I find the file with the output. I am using a 4 core processor and no local network farm or cloud network testing an EA in OHLC mode. Any ideas what could be wrong? I have looked through the forum and articles and can't seem to find an answer. Many thanks for your help.

Here is my code:

Did you check the correct directory for the file? The manual explains that the location where the file will be written depends on whether you are running a test or using in normal trading mode.

The manual page: https://www.mql5.com/en/docs/files/fileopen

contains the sentence : "The file is opened in the folder of the client terminal in the subfolder MQL5\files (or testing_agent_directory\MQL5\files in case of testing). "

Documentation on MQL5: File Functions / FileOpen
Documentation on MQL5: File Functions / FileOpen
  • www.mql5.com
[in]  The name of the file can contain subfolders. If the file is opened for writing, these subfolders will be created if there are no such ones. [in]  value to be used as a separator in txt or csv-file. If the csv-file delimiter is not specified, it defaults to a tab. If the txt-file delimiter is not specified, then no separator is used. If...
 

Hi,

Thankyou for your help both of you. I misunderstood how it works and that it's only during Optimization not during a single test. The file I found in the Tester subfolder not MQL5\Files

Reason: