Problem with reading txt files in MT5 tester

Rene Balke  

Hi guys,

today I experienced a very strange EA behavior when i tried to read from a txt file in the MT5 tester. The file is located in the "normal" terminal folder and should be loaded by using #property tester_file. Since it did not work with the txt file I also tried opening a csv file. Now the weird part: The EA opened the csv file while opening the txt file failed with an 5004. Both files exist and can be read in live trading:

Results in live trading:

2020.04.02 15:20:51.337 Classes (EURUSD,M5)     test.txt
2020.04.02 15:20:51.338 Classes (EURUSD,M5)     beispiel.csv

Results in tester:

2020.04.02 15:27:58.872 2019.05.03 00:00:00   Error: 5004
2020.04.02 15:27:58.872 2019.05.03 00:00:00   beispiel.csv

I just do not get what is causing the problem here. Anyone experienced this before? What am i missing here?

Thanks for any hint!

Best regards, 

René


Please see the code I use below:

#property tester_file "test.txt"
#property tester_file "beispiel.csv"

int OnInit(){
   ResetLastError();
   string fileName = "test.txt";
   int fileHandle = FileOpen(fileName,FILE_TXT|FILE_READ,";");
   if(fileHandle != INVALID_HANDLE){
      Print(fileName);
      FileClose(fileHandle);
   }else Print("Error: ",GetLastError());
   
   ResetLastError();
   fileName = "beispiel.csv";
   fileHandle = FileOpen(fileName,FILE_CSV|FILE_READ,";");
   if(fileHandle != INVALID_HANDLE){
      Print(fileName);
      FileClose(fileHandle);
   }

   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){

}

void OnTick(){

}
Rene Balke  

Hey, thanks for the reply. This post seems to be several years old and refers to the MT4. My problem only appears when I try to open the .txt file in the MT5 tester.

nicoclaase  

Hi hi


Apologies, this is not the correct place, but here goes.


I have 2 laptop stations. One connected to a paper MT5 account, one connected to a live account MT5.

I would like a copy trader that does the following:

1) When I or a robot opens a trade on the paper account, the order must go through to the live account but it must be inverted.

2) Once the paper account sets a stop loss ( by me or a robot ), the order must be generated and sent to the live account to the same value, opposite direction as well.

3) Once the paper account sets a take profit ( by me or a robot ) , the order must be generated and sent to the live account to the same value, opposite direction as well.


I must be able to interrupt the program at anytime to take the profit or loss manually on the live account.


In short, everything I or a robot does on the paper account must be inverted and traded on the live account and I must be able to manually take a profit or loss on the live account. So the reversing program should likely be on the paper account MT 5.


Kind regards


Nico

nicoclaase  
Are you on facebook? I can send a message there too?
Sergey Golubev  
nicoclaase:

...

I have 2 laptop stations. One connected to a paper MT5 account, one connected to a live account MT5.

...


...
You can find something in the Market using this search results link, or order the tool in Freelance for example.
William Roeder  
Rene Balke #: Hey, thanks for the reply. This post seems to be several years old and refers to the MT4. My problem only appears when I try to open the .txt file in the MT5 tester.

Old, but you still made the same mistake. MT4, but you still made the same mistake. Reread the last post in the link.

Reason: