Failing to export data to csv thrugh the back tester please assist

 
When the back tester stops the csv has nothing
void OnTick()
  {
      int MyExternalFile = FileOpen("tate.csv",FILE_WRITE|FILE_CSV);
      FileWrite(MyExternalFile,NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),_Digits),1);
      FileFlush(MyExternalFile);
      FileClose(MyExternalFile);
      
  }
 
int MyExternalFile;

int OnInit()
  {
      MyExternalFile = FileOpen("tate.csv",FILE_WRITE|FILE_CSV);
      return 0;
  }

void OnDeinit(const int reason)
  {
      FileClose(MyExternalFile);
  }

void OnTick()
  {
      FileWrite(MyExternalFile,NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),_Digits),1);
      //FileFlush(MyExternalFile); <- no need to do this
  }
 
lippmaje:
Thank you, I tried it but the back tester does not even take anytime it immediately and they is nothing in the csv. 
 
My apologizes it work I was making a mistake of looking for the file in terminal files. Thank you very much
 
Hi, I'm having similar trouble.  Where are the Tester CSV's saved to?  I've been looking in the Terminal folder, either in Files, or Tester folders and can't find anything.  I've run my function as a script and it creates a CSV in the 'Files' folder when dropped on a chart?  I've been attempting to run in the OnTester() function to generate at end of backtests.
 

On Windows 7 it's here: <MT5 Installation Folder>\Tester\Agent-127.0.0.1-3000\MQL5\Files\file.csv

 
lippmaje:

On Windows 7 it's here: <MT5 Installation Folder>\Tester\Agent-127.0.0.1-3000\MQL5\Files\file.csv

Thanks for the info but I can't find it here either.  It's printing a 'FileOpen OK' message in the journal, so appears to be running, but no sign of a file.  I also searched in the whole MetaQuotes folder for the filename and nothing appeared.

As I said, the code works fine in a script, but doesn't seem to create the CSV correctly from OnTester().  Any input to this would be greatly appreciated.

string File_Name;

double OnTester()
   {
   ResetLastError();
   File_Name = "Test1.csv";
   int Handle = FileOpen(File_Name, FILE_CSV | FILE_WRITE);

   if(Handle != INVALID_HANDLE)
      {
      FileSeek(Handle, 0, SEEK_END);
      FileWrite(Handle, "Hello");
      FileClose(Handle);
      Print("FileOpen OK");
      }
   else Print("FileOpen Failed, error ",GetLastError());

   return(0);
   }
Reason: