Failing to export data to csv thrugh the back tester please assist
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 }
On Windows 7 it's here: <MT5 Installation Folder>\Tester\Agent-127.0.0.1-3000\MQL5\Files\file.csv
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); }