Page 1 of 1

Exported file from indicator gets locked by MC

Posted: May 16 2024
by amadeu1
Dear All

When I test a new trading strategy I open a chart with 5min data , apply a signal and also a propietray indicator that exports information like an equityline or something else to a folder . A second software uses that file for further calculations. While MC is open I cannot delete that exported file because it is somehow locked by MC. (see attachment)


Lets take a simple example as an indicator:

if BarNumber = 1 then
begin
FileDelete("c:/mctrades/"+symbol+".txt");
FileAppend("c:/mctrades/"+symbol+".txt","123");
end;



This indicator creates a file that I cannot delete anymore while MC is open. I have to close MC to be able to delete that file. In older versions of MC that was possible but now does not work anymore. How can resolve this ?

Re: Exported file from indicator gets locked by MC

Posted: May 22 2024
by Polly MultiCharts
Hello amadeu1,

In order for a file to be deleted, its descriptor should be closed. Please use FileClose to close a file descriptor. It closes the handle of the specified file, which allows for opening it from a different application for writing.

Re: Exported file from indicator gets locked by MC  [SOLVED]

Posted: May 22 2024
by amadeu1
Thanks -- that solved the problem