MQL - error 4102 (too many opened files)

 
Hi all,
I have problem with this error:
error#: 4102
ERR_TOO_MANY_OPENED_FILES

Any one know what cause it? What I must do for skipping this?

thnx
 
See https://docs.mql4.com/files/FileOpen

int FileOpen( string filename, int mode, int delimiter=';')
Opens file for input and/or output. Returns a file handle for the opened file or -1 (if the function fails). To get the detailed error information, call GetLastError() function.
Notes: Files can only be opened in the terminal_directoryexpertsfiles folder (terminal_directory esterfiles if for expert testing) or in its subfolders.
FILE_BIN and FILE_CSV modes cannot be used simultaneously.
If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.
If FILE_READ does not combine with FILE_WRITE, the file will be opened only if it already exists. If the file does not exist, it can be created using the FILE_WRITE mode.
No more than 32 files can be opened within an executable module simultaneously. Handles of files opened in the same module cannot be passed to other modules (libraries).
Parameters:
filename - Filename.
mode - Opening mode. It can be one or combination of values: FILE_BIN, FILE_CSV, FILE_READ, FILE_WRITE.
delimiter - Delimiter character for csv files. By default, the ';' symbol applies.
Sample:
  int handle;
handle=FileOpen("my_data.csv",FILE_CSV|FILE_READ,';');
if(handle<1)
{
Print("File my_data.dat not found, the last error is ", GetLastError());
return(false);
}
 
rigth but I had'nt 32 files open!
 
May be you (your expert advisor) often open file and forget to "close" it?
 
I had checked it. I close them after each open. but I wil check it again anyway.
Is it possible that I open a non-exist file with FILE_READ and so it return -1.
then it cant close it, because nothing has opened, but it decrement from MAX_OPEN_FILES (32) counter.
?
 
oh, I'm silly
you were right
I add some counter to check whrere I open and close my files and find somewhere that I return before fileClose();
thanks,
 
"Never say never" ;)

You're welcome.
Reason: