ERROR 4024 MQL BUG

 

Hello my dear coding and trader friends.

So, recently I came across a new funny problem^^ 
Function of the code: Open New Chart --> Apply Template --> Take Screenshot --> Close Chart.

But in 30% an error occures. ERROR 4024.  The Chart Opens, but It doesnt return the Chart ID. I've programmed a little workaround where I check if there are now mow Charts open, if yes I just select the latest one.

4024

ERR_INTERNAL_ERROR

Internal error

But Is there a clean version to avoid that bug or a better workaround? 

Yes I know there are already simmilar topics in the forum but I couldn't find any with a solution.

So is there anyone who solved this problem in a cleaner way?

//Open Chart
        long chartID = ChartOpen(_symbol, _period);  
        int attempt = 1;
        
        while(chartID == 0 && attempt < 5)
        {
        	printf("%i. Attempt to open a new Chart failed! Error %i", attempt, GetLastError());
                Sleep(1000);    //Wait 1 Sec then try again
                
                chartID = ChartOpen(_symbol, _period); 
                attempt ++;
        }
        
        if(chartID > 0) { printf("Successfully Opend New Chart at %i attempt, %s %s", attempt, _symbol, EnumToString(_period)); }
        else                             { printf("Chart Open failed! %s %s", _symbol, EnumToString(_period)); return 0; }


Error Logs:

0 09:09:58.753 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: Currently Open Charts 12

0 09:10:03.786 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: 1. Attempt to open a new Chart failed! Error 4024

0 09:10:14.508 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: 2. Attempt to open a new Chart failed! Error 4024

0 09:10:25.219 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: 3. Attempt to open a new Chart failed! Error 4024

0 09:10:35.971 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: 4. Attempt to open a new Chart failed! Error 4024

0 09:10:46.672 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: Chart Open failed! EURGBP PERIOD_M15

0 09:10:46.797 MT4_to_Telegram_Signal_Provider_1_4 GBPUSD,H1: Failed sending screenshot! Send only caption instead, Error: -1

 
Someone?