How can I read a file in mt5 tester?

How can I read a file in mt5 tester?

Manage alerts

Loading saved threads...

Aftershock · External communityPost link
External question — Stack Overflow Stack Exchange Author: Aftershock Original post: https://stackoverflow.com/questions/76044467 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. This code works when it does not run in the tester... How can I load this file when running this code (an EA) in the tester. The file is located under mql5/Files but that does not work when running this code in the tester. int OnInit() { //--- file_handle=FileOpen(Csv,FILE_READ|FILE_CSV|FILE_SHARE_READ,','); if(file_handle==INVALID_HANDLE) { Alert("could not open file "+Csv," Error: ",GetLastError()); return INIT_PARAMETERS_INCORRECT; } return(INIT_SUCCEEDED); } One solution is to copy the file into testing_agent_directory\MQL5\files... But this needs to be done repeatedly...(Based on the suggestion by PaulD) as the files gets deleted at the end of the simulation. Does anyone have a better solution?
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange Author: PaulB Original post: https://stackoverflow.com/a/76044583 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox. FileOpen(file_name, open_flags, delimiter, codepage) According to the documentation, the file is opened in the folder of the client terminal in the subfolder MQL5\files (or testing_agent_directory\MQL5\files in case of testing). You therefore need to change the location of your files to be opened when testing.
Quote
Report
Charles Roberto Canato · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Charles Roberto Canato Original post: https://stackoverflow.com/a/79724374 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I still didn't find anywhere a reason for this (ok, didn't search that hard), but I guess that this might be related to anything created inside a testing session being cleaned after execution. Of course, for input stuff, this is a headache. So far my best way to block that was by explicitly denying permissions to delete under Windows security properties tab. You must deny it on the directory, not on the file itself. I have denied it to Everyone, but, denying it only for your own user might have the same effect.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: PaulB Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/a/76044583 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox. FileOpen(file_name, open_flags, delimiter, codepage) According to the documentation, the file is opened in the folder of the client terminal in the subfolder MQL5\files (or testing_agent_directory\MQL5\files in case of testing). You therefore need to change the location of your files to be opened when testing.

Cancel quote

Checking account access…