custom indicator cause freezing

 

hi experts

i'm trying to develop a custom indicator but at this stage it's getting very heavy and mostly cause the mt4 frozen 

i wonder there is some general instruction  for for optimizing the code so or even a tool to show which part of the code cause the frozen problem 

 
Seyedmasoud Hashemi:

hi experts

i'm trying to develop a custom indicator but at this stage it's getting very heavy and mostly cause the mt4 frozen 

i wonder there is some general instruction  for for optimizing the code so or even a tool to show which part of the code cause the frozen problem 

The best solution is to switch to MT5.

 
Ahmet Metin Yilmaz:

The best solution is to switch to MT5.

beside that 

some software like matlab have option to determinate how much time need for processing each function(or line as i remember) 

i wonder if  such thing exist for mql4

 
Seyedmasoud Hashemi: it's getting very heavy and mostly cause the mt4 frozen 

i wonder there is some general instruction  for for optimizing the code so or even a tool to show which part of the code cause the frozen problem 

  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. If it is freezing MT4, that means you are not returning. You do not optimize that, you fix your broken indicator.
  3. Yes, there is a tool. It's call the profiler; built in to the editor.
  4. Once you start getting messages about the indicator taking too long, then, as a last resort, use my segmented OnCalculate include file.
              Your indicator is too slow... - Indices - MQL4 programming forum #1 № 6
 
William Roeder:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. If it is freezing MT4, that means you are not returning. You do not optimize that, you fix your broken indicator.
  3. Yes, there is a tool. It's call the profiler; built in to the editor.
  4. Once you start getting messages about the indicator taking too long, then, as a last resort, use my segmented OnCalculate include file.
              Your indicator is too slow... - Indices - MQL4 programming forum #1 № 6

sorry for my mistake 

your answer was helpful

apparently this section of  my code for deleting object that called by multi time is problem:

void MegaDelete(int shift)
  {
  

  int j=Time[shift];
   for(int i=ObjectsTotal(0,-1,-1); i>=0; i--)
   {
      if(StringFind(ObjectName(i), IntegerToString(j))==11&& StringFind(ObjectName(i), RSILine)!=-1)
      {
         ObjectDelete(0,ObjectName(i));
         
         }
         if(StringFind(ObjectName(i), IntegerToString(j))==13&& StringFind(ObjectName(i),  PriceLine)!=-1)
         {
         ObjectDelete(0,ObjectName(i));
          }
      
}

this code give a int and compare all object to find a object with certain character in there (and their places in the names)

there is better way to write it ?

 
Give all your objects the same pattern, i.e.  WindowExpertName()+nnn and delete them all with ObjectsDeleteAll(0,WindowExpertName())