Código de error 5004 - página 4

 
samoye: ¿Hay alguna solución para el error 5004, por favor? Estoy recibiendo el mismo mensaje de error al intentar escribir en un archivo.
Preguntado y respondido. Abra el archivo una vez antes del bucle. Cierre el archivo después del bucle.
 

Hola

parece que el error 5004 está relacionado con no cerrar el archivo.


int readFileImg (string file_name) {

   int filehandle = FileOpen(file_name, FILE_READ|FILE_BIN);

   if (filehandle!=INVALID_HANDLE) {

      FileClose(filehandle);  // this line is important, without this line you will get 5004

      Alert("done");

   } else Alert("Operation FileOpen failed, error ",GetLastError(), TerminalInfoString(TERMINAL_DATA_PATH));

   return filehandle;

}

 

Por favor, utilice el botón </> para insertar su código.


 

Tengo el mismo error 5004 apareciendo al probar el EA usando Strategy Tester. Debe ser un error en mt4 ya que puede abrir otros archivos en la misma sesión pero de repente no puede abrir archivos.

Yo uso esto para backtesting un algoritmo de aprendizaje de la máquina.

Ahora necesito otra plataforma para backtesting el algoritmo ya que mt4 no funciona.

¿Alguna idea sobre otras plataformas de backtesting?

Preferiblemente basadas en python.

 
Prueba con MT5.
 
kypa:
Pruebe con MT5.

Estoy tratando de depurar mi programa y estoy teniendo el mismo problema.

Basándome en el ejemplo de FileOpen Docs, he creado esta función para leer una lista de símbolos de un archivo.

Incluí el archivo en el "Directorio de Archivos" del editor y llamo a la función así:


GetSymbolsFromFile("carteiras","ibrx_100_2018_12_10.txt");
//+------------------------------------------------------------------+
//| Get the symbols                                                  |
//+------------------------------------------------------------------+
void TProgram::GetSymbolsFromFile(const string filePath, const string fileName)
{
   //--- additional variables 
   int    str_size; 
   string str;
   int    array_size;
   string terminal_data_path;
   
   //--- open the file 
   ResetLastError(); 
   //--- Release the symbol array
   ::ArrayFree(m_file_symbols);
   
   terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   PrintFormat("File path: %s\\Files\\",terminal_data_path);
   
   bool  test1 = FileIsExist(fileName,0 );
   bool  test2 = FileIsExist(fileName,FILE_COMMON);
   
   int file_handle=FileOpen(fileName,FILE_READ|FILE_TXT|FILE_ANSI); 
   if(file_handle!=INVALID_HANDLE) 
   { 
      PrintFormat("%s file is available for reading",filePath); 
      //PrintFormat("File path: %s\\Files\\",terminal_data_path);
      //--- read data from the file 
      while(!FileIsEnding(file_handle)) 
        { 
         //--- find out how many symbols are used for writing the time 
         str_size=FileReadInteger(file_handle,INT_VALUE); 
         //--- read the string 
         str=FileReadString(file_handle,str_size); 
         
         array_size=::ArraySize(m_file_symbols);
         ::ArrayResize(m_file_symbols,array_size+1);
         m_file_symbols[array_size]=str;
         
         //--- print the string 
         PrintFormat(str); 
        } 
      //--- close the file 
      FileClose(file_handle); 
      PrintFormat("Data is read, %s file is closed",fileName); 
   }
   else
   {
      PrintFormat("Failed to open %s file, Error code = %d",fileName,GetLastError()); 
   }
}

Probé muchos parámetros y filePaths diferentes

1 - Traté de usar la ruta del archivo termal y nada de esto funciona.

 int file_handle=FileOpen(fileName,FILE_READ|FILE_TXT|FILE_ANSI); 

Tengo los errores 5002 e 5004

ERR_WRONG_FILENAME

5002

Nombre de archivo inválido

ERR_CANNOT_OPEN_FILE

5004

Error de apertura de archivo

Archivos adjuntos:
Razón de la queja: