metatrader doenot delete my indicator by ChartIndicatorDelete

 

hi 

I want to delete all indicators from my chart by running a piece of code in my expert or script 

but it doesnot work properly .

some times delete one from 5 indicators, some times 2 .

and also it has delay!!!

please help me what can I do to insure the proper answer from metetrader

   void OnStart()
  {
   string ind_name;
   int km=WindowsTotal();
   Print("wintotal  ",km);

   for(int k=0; k<km; k++)
     {
      int pm=ChartIndicatorsTotal(0,k);
      Print(" wind ", k," ind total: ",pm);
      for(int p=0; p<pm; p++)
        {
         ind_name=ChartIndicatorName(0,k,p);
         //INDICATOR_SHORTNAME

         if(ChartWindowFind(0,ind_name)==k)
           {
            Print("window ", k);
            if(!ChartIndicatorDelete(0,k,ind_name))
              {
               Print(ind_name); 
               Print("error : ",_LastError);
              }
           }
        }
     }
}


also I have error : 0  in expert tab for all indicators !!

you can see a sample report from expert tab in attached pic.

one custom indicator has been deleted by 15s delay!!

metatrader 's indicator ( AO) did not deleted !!

.

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
Files:
11.jpg  145 kb
 
Mehrdad Sarrafi:

hi 

I want to delete all indicators from my chart by running a piece of code in my expert or script 

but it doesnot work properly .

some times delete one from 5 indicators, some times 2 .

and also it has delay!!!

please help me what can I do to insure the proper answer from metetrader


also I have error : 0  in expert tab for all indicators !!

you can see a sample report from expert tab in attached pic.

one custom indicator has been deleted by 15s delay!!

metatrader 's indicator ( AO) did not deleted !!

.

THIS IS A BUG IN METATRADER.

HOW CAN I REPORT THIS BUG ?!


can anybody help me ?

i have reported a bug 7 years ago throu  Service  Desk  . but now I cannot ! 

 

Hello
I'm sorry, my help will not be very great


there may be a problem getting the function to return, which could explain the high delay of 15 seconds.
The indicators you are trying to close may not have exclusive access and cannot be closed.

It will further lengthen the delay, but in this case, I think you should replace your "for" loop with a "while"

If there is a solution, it should be in preparation for clearing these flags, such as removing handles

Sorry, for not being able to do more

 

Have you tried counting loop in reverse? When removing things it is better to do so. Because of the FIFO nature of the queue.

 
Mehrdad Sarrafi #:

THIS IS A BUG IN METATRADER.

HOW CAN I REPORT THIS BUG ?!


can anybody help me ?

i have reported a bug 7 years ago throu  Service  Desk  . but now I cannot ! 

This is not an MT5 bug, fix your code and understanding.
 
Alain Verleyen #:
This is not an MT5 bug, fix your code and understanding.


this is a bug as you see in the attached  pic 

but it is in mt4 . (where I said this bug is in MT5 ?!!)

which part of my code has problem?

 
Mehrdad Sarrafi #:


this is a bug as you see in the attached  pic 

but it is in mt4 . (where I said this bug is in MT5 ?!!)

which part of my code has problem?

If it's MT4, then post in MT4 section. Moved.

Anyway, this is not a bug in the platform. Fix your code and understanding.

 
Yashar Seyyedin #:

Have you tried counting loop in reverse? When removing things it is better to do so. Because of the FIFO nature of the queue.

thank you very much . great hint 

I had encountered  this problem and  used this solution a few years ago, when I want to delete market watch's symbols. but  ...

now it works very nice

 
Gerard Willia G J B M Dinh Sy #:

Hello
I'm sorry, my help will not be very great


there may be a problem getting the function to return, which could explain the high delay of 15 seconds.
The indicators you are trying to close may not have exclusive access and cannot be closed.

It will further lengthen the delay, but in this case, I think you should replace your "for" loop with a "while"

If there is a solution, it should be in preparation for clearing these flags, such as removing handles

Sorry, for not being able to do more

thank you very much for consultation

Mr yashar Seyyedin 's hint solved the problem , that is a good lesson for a programmers, 

although I think MT4 's response was iregullar and  strange . 

 
Alain Verleyen #:

If it's MT4, then post in MT4 section. Moved.

Anyway, this is not a bug in the platform. Fix your code and understanding.

   string ind_name;
   int kmax,pmax;
   kmax=WindowsTotal();
   for(int k=kmax-1; k>=0; k--)
     {
      pmax=ChartIndicatorsTotal((long)0,k);
      for(int p=pmax-1; p>=0; p--)
        {
         ind_name=ChartIndicatorName((long)0,k,p);
         if(!ChartIndicatorDelete((long)0,k,ind_name))
           {
            Print(ind_name);
            Print("error : ",_LastError);
           }
        }
     }

you know , beside counting loop in reverse , I should add typecasting zero to the long in main 3 function of this program !!!

othervise it doesnot work properly and each time only delete one indicator !! 

could you please tell the reason ?

Reason: