Codice di errore 5004 - pagina 4

 
samoye: C'è una soluzione all'errore 5004 per favore? Sto ricevendo lo stesso messaggio di errore cercando di scrivere su un file.
Chiesto e risposto. Aprire il file una volta prima del ciclo. Chiudi il file dopo il ciclo.
 

ciao

sembra che l'errore 5004 sia legato alla mancata chiusura del file!


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;

}

 

Usa il pulsante </> per inserire il tuo codice.


 

Ho lo stesso errore 5004 che salta fuori mentre provo l'EA usando Strategy Tester. Deve essere un bug in mt4, dato che può aprire altri file nella stessa sessione, ma improvvisamente non può aprire i file.

Lo uso per il backtesting di un algoritmo di apprendimento automatico.

Ora ho bisogno di un'altra piattaforma per il backtesting dell'algoritmo dato che mt4 non funziona.

Qualche idea su altre piattaforme di backtesting?

Preferibilmente basata su python.

 
Prova MT5.
 
kypa:
Prova MT5.

Sto cercando di eseguire il debug del mio programma e sto avendo lo stesso problema.

Basandomi sull'esempio nei documenti di FileOpen, ho creato questa funzione per leggere un elenco di simboli da un file.

Ho incluso il file nella "directory dei file" dell'editor e chiamo la funzione in questo modo:


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()); 
   }
}

Ho provato diversi parametri e filePaths

1 - Ho provato ad usare il percorso del file terminale e niente di tutto ciò funziona.

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

Ho gli errori: 5002 e 5004

NOME_DI_FILM_ERRATO

5002

Nome file non valido

ERR_CANNOT_OPEN_FILE

5004

Errore di apertura del file

Motivazione: