Help with "csv Locked for Editing"

 

Hi,


I am using one of the indicators i.e. "Period_Converter_Opt.mq4" to create custom timeframe data from MT4 and save it as csv file.


However, while the indicator is running, I cannot access the file using other softwares and hence, cannot update it or access it from other softwares. When I try to open the file directly, I get the message "csv is Locked for Editing". Kindly help out

 
Just to add to the above problem, the other program can open the file before the indicator is used in MT4. However, after the application is used in MT4, the file can no longer be updated in the other program.
 
lalthan wrote >>
Just to add to the above problem, the other program can open the file before the indicator is used in MT4. However, after the application is used in MT4, the file can no longer be updated in the other program.

Take a look at this link from the mql4 book discussing file operations.

https://book.mql4.com/functions/files

In particular

Modes of File Operations


The technology of interaction between an application and a working file has several modes. In general, a file can be opened by several programs at the same time (within a PC or several PCs connected to the network). At the same time, the operational environment provides the full access to the file, namely the right to read the file and write the information in it, only to one program. The other programs can only read it. For example, if My_text.doc has already been opened by a text editor, then all the other programs will receive the notification before opening the file:


Fig. 146. Dialog box that appears when a program tries to access to the file that has already been opened by another program.

The execution of this technology guaranties that a file won't be modified simultaneously by two different programs.

WINDOWS can not allow 2 applications write access to the same file at the same time because it will not be able to excercise version control. Try it on your PC with any other file. You will not be able to open the same file with more than 1 instance of the same application or even more than 1 application at the same time. It is not allowed by the operating system. The same rules apply to MT4.

Sorry, but you will not be able to do it.

Maybe you can try to open the file in read only mode, but then you will obviously not be allowed to edit it.

whocares

 

Got it resolved now.


The code only flushes the csvhandle instead of closing it and hence, remained locked for external use.

Reason: