Exported file from indicator gets locked by MC  [SOLVED]

Questions about MultiCharts and user contributed studies.
amadeu1
Posts: 77
Joined: 11 Feb 2008
Has thanked: 1 time
Been thanked: 8 times

Exported file from indicator gets locked by MC

Postby amadeu1 » 16 May 2024

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 ?
Attachments
ScreenHunter 1172.jpg
(61.66 KiB) Not downloaded yet

User avatar
Polly MultiCharts
Posts: 218
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 59 times

Re: Exported file from indicator gets locked by MC

Postby Polly MultiCharts » 22 May 2024

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.

amadeu1
Posts: 77
Joined: 11 Feb 2008
Has thanked: 1 time
Been thanked: 8 times

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

Postby amadeu1 » 22 May 2024

Thanks -- that solved the problem


Return to “MultiCharts”