how to read external parameter from csv than update it ontester

 

i want to read an external parameter from csv, use it on tester, and then after each test pass update those parameter and write it back to csv.

i try to put the imported parameter as global variable, so does with file name string.

i use slow complete algorithm and optimization target was input count variable (0-500)

then i put the read csv code at onTesterInit(), while the code for updating csv i put it on OnTesterPass().

i've tried to move the write csv code to OnTesterDeinit(), but still not working.

please point me how to do this. thanks.

my simple code are as follow:

   input int      counts   =  0;
   double         extinput;
   string         flname   =  "DataTest.csv";


//+------------------------------------------------------------------+
//| TesterInit function                                              |
//+------------------------------------------------------------------+
void OnTesterInit()
  {
//---
      int   fhandle=FileOpen(flname,FILE_READ|FILE_CSV|FILE_COMMON,",");
      if(fhandle!=INVALID_HANDLE)
         {
            extinput =  FileReadDouble(fhandle);

         }else
            {
               Print("File Open Failed");
            }
            
      FileClose(fhandle);
      
      extinput +=1;
  }
//+------------------------------------------------------------------+
//| TesterPass function                                              |
//+------------------------------------------------------------------+
void OnTesterPass()
  {
//---
      int   fhandle=FileOpen(flname,FILE_WRITE|FILE_CSV|FILE_COMMON);
      if(fhandle!=INVALID_HANDLE)
         {
            FileWriteDouble(fhandle,extinput);

         }else
            {
               Print("File Open Failed");
            }
            
      FileClose(fhandle);
  }
 
adicahyanto:

i want to read an external parameter from csv, use it on tester, and then after each test pass update those parameter and write it back to csv.

i try to put the imported parameter as global variable, so does with file name string.

i use slow complete algorithm and optimization target was input count variable (0-500)

then i put the read csv code at onTesterInit(), while the code for updating csv i put it on OnTesterPass().

i've tried to move the write csv code to OnTesterDeinit(), but still not working.

please point me how to do this. thanks.

my simple code are as follow:

I think you will find answer in https://www.mql5.com/en/forum/367098
Where to locate files for Strategy tester to find them
Where to locate files for Strategy tester to find them
  • 2021.04.12
  • www.mql5.com
MT5 has a very bizarre way of handling files...
Reason: