Código de erro 5004 - página 4

 
samoye: Existe uma solução para o erro 5004, por favor? Estou recebendo a mesma mensagem de erro ao tentar escrever em um arquivo.
Perguntado e respondido. Abrir o arquivo uma vez antes do laço. Feche o arquivo após o laço.
 

ei

parece que o erro 5004 está relacionado ao não fechamento do arquivo!


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;

}

 

Favor usar o botão </> para inserir seu código.


 

Tenho o mesmo erro 5004 aparecendo ao testar o EA usando o Testador de Estratégia. Deve ser um erro no mt4, pois pode abrir outros arquivos na mesma sessão, mas de repente não pode abrir arquivos.

Uso isto para fazer um backtesting de um algoritmo de aprendizado de máquina.

Agora eu preciso de outra plataforma para fazer o backtesting do algoritmo, uma vez que o mt4 não funciona.

Alguma idéia sobre outras plataformas de backtesting?

Preferivelmente baseado em python.

 
Experimente o MT5.
 
kypa:
Experimente o MT5.

Estou tentando depurar meu programa e estou tendo o mesmo problema.

Baseado no exemplo do FileOpen Docs, criei esta função para ler uma lista de símbolos a partir de um arquivo.

Incluí o arquivo no "Diretório de Arquivos" do editor e chamo a função dessa forma:


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

Eu tentei muitos parâmetros e caminhos de arquivo diferentes

1 - Tentou usar o caminho do arquivo térmico e nada disso funciona.

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

Eu recebi os erros: 5002 e 5004

ERR_WRONG_FILENAME

5002

Nome do arquivo inválido

ERR_CANNOT_OPEN_FILE

5004

Erro de abertura do arquivo

Arquivos anexados:
Razão: