Symbol() not working in deinit() - can that be?

 

Hi,

it took me hours today but as long as I had Symbol() in the deinit() function (in order to delete a market specific file)
my terminal (build 509) seems to run into an endless loop with max cpu-time consuming - anybody who can confirm?

As soon as I replaced Symbol() by a global var SYM set at init(){ SYM = Symbol(); .. } the spook was over.

Are there other function that won't work in deinit(). Better to know that to find out the hard way.

Gooly

 
gooly:

Hi,

it took me hours today but as long as I had Symbol() in the deinit() function (in order to delete a market specific file)
my terminal (build 509) seems to run into an endless loop with max cpu-time consuming - anybody who can confirm?

As soon as I replaced Symbol() by a global var SYM set at init(){ SYM = Symbol(); .. } the spook was over.

Are there other function that won't work in deinit(). Better to know that to find out the hard way.

Gooly

Can you post compilable and executable code to reproduce the problem please, a test script will do.
 

ok.

I want to use the 'news-bell' from here: http://www.forexfactory.com/showthread.php?t=19293

Due to the Error messages of FileDelete() because of the restricted file management in MT4 I started changes to use WinFile.mqh

But the attached file is the original one - exept deinit().

I deleted this:

        // Fixed one case of divide by zero where multiple charts 
        // indicator is on was trying to overwrite the same file
        xmlFileName = GetXmlFileName();
        xmlHandle = FileOpen(xmlFileName, FILE_BIN|FILE_READ|FILE_WRITE);

        // File does not exist if FileOpen return -1 or if GetLastError = ERR_CANNOT_OPEN_FILE (4103)
        if (xmlHandle >= 0)
        {
                // Since file exists, Close what we just opened
                FileClose(xmlHandle);
                
                // Delete our news file and redownload a new one to prevent a remainder from zero divide error
                if (!SaveXmlFiles)
                        FileDelete(xmlFileName);
        }

and put my code ( finally ) in the beginning:

        Alert("Start deinit() "); // Line 296
        
        for (i=1;1<30;i++) { // Line 298
                xmlFileName = (DayOfYear()-i)+"-"+Symbol()+"-FFCal.xml";
                FileDelete( xmlFileName );
        }
        Alert("Del ",xmlFileName," Err",GetLastError()); // line

in my version I changed the filename like that:

xmlFileName = (DayOfYear()-i)+"-"+Symbol()+"-FFCal.xml";

but it should make any difference! It tries to delete a non existing file - so what. Later in that Indicator this is used to be able to re-write the xml-file and it causes every time an error message in the expert tab:

                        // Delete existing file // line 413
                        FileDelete(xmlFileName);
                        
                        // Write the contents of the ForexFactory page to an .htm file
                        // If it is still open from the above FileOpen call, close it.
                        xmlHandle = FileOpen(xmlFileName, FILE_BIN|FILE_WRITE);

Now I opened two charts EURUSD in both I installed FFCalOrg.

If I now force one of the Indicators to deinit() by changing e.g. the timeframe I am caught in the endless loop.

If disable just this:

/*
        for (i=1;1<30;i++) { 
                xmlFileName = (DayOfYear()-i)+"-"+Symbol()+"-FFCal.xml";
                FileDelete( xmlFileName );
        }
        Alert("Del ",xmlFileName," Err",GetLastError());
*/

and compile it and restart the terminal I don't have any endless loop.


I have no idea, why I finally found a working solution, but I have spend so much time on that, I am sorry to say, I lost the lust to investigate further...

Have fun guys

Files:
ffcalorg.mq4  47 kb
 
gooly:

ok.

If I now force one of the Indicators to deinit() by changing e.g. the timeframe I am caught in the endless loop.

What do you expect . . . one is always less than thirty . . .

for (i = 1; 1 < 30; i++)
 
sigh, you're right..
 
gooly:
sigh, you're right..
Sorry, but have to do this . . . .
Reason: