Download MetaTrader 5

File write error

To add comments, please log in or register
Samuel Oyeniyi
379
Samuel Oyeniyi  

I am getting an error message while attempting to write to a file location.

 

0 16:13:12.522 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

0 16:13:12.523 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

0 16:13:12.525 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

0 16:13:12.526 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

0 16:13:12.529 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

0 16:13:12.530 HL GBPCHF,Daily: Alert: hist0935 Events File Error.5004

 

Can somebody please help? 

//+------------------------------------------------------------------+
//| expert count strategy open position function  (openPos)          |
//+------------------------------------------------------------------+
void closedPos() {  

   int file=FileOpen("hist0935.csv",FILE_WRITE|FILE_CSV);
   
  
      
for(int i=OrdersHistoryTotal()-1; i>=0; i--) {

int file=FileOpen("hist0935.csv",FILE_WRITE|FILE_CSV);

ResetLastError();
file=FileOpen("hist0935.csv",FILE_WRITE|FILE_CSV);


      OrderSelect(i, SELECT_BY_POS, MODE_HISTORY); 

  if (file != INVALID_HANDLE){    

   PrintFormat("%s file is available for writing",file);
  
   
      FileWrite(file,OrderTicket(),OrderClosePrice(),OrderCloseTime());
      
      //--- close the file
     Print("error="+GetLastError());
      FileClose(file);
      PrintFormat("%s file is closed",file);
       
 }else{
      Alert("hist0935 Events File Error.",GetLastError());
  }
  
   }        
}
whroeder1
15576
whroeder1  
int file=FileOpen("hist0935.csv",FILE_WRITE|FILE_CSV);
for(int i=OrdersHistoryTotal()-1; i>=0; i--) {
    int file=FileOpen("hist0935.csv",FILE_WRITE|FILE_CSV);
  1. You open the file but don't check for an error What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. Then you try to open the file again, which fails. And you've lost the handle so you can't ever close it.
  3. Open once. Wight your data in the loop. Close after the loop.
Samuel Oyeniyi
379
Samuel Oyeniyi  
WHRoeder:
  1. You open the file but don't check for an error What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. Then you try to open the file again, which fails. And you've lost the handle so you can't ever close it.
  3. Open once. Wight your data in the loop. Close after the loop.
Thank you.
To add comments, please log in or register