MT4 platform freezes when I try to remove one of my custom indicators!

 

Here is the deinit().  Could this be the problem?


int deinit()

{

ObjectsDeleteAll(0, 23);

    for(int a = ObjectsTotal();  a >= 0;  a--)

    {

        string name = ObjectName(a);

        if(ObjectType(name) == OBJ_TREND && (StringFind(name,"DP_Line") >= 0 ||

        StringFind(name,"SW_Line") >= 0))

            ObjectDelete(name);

    }

    

return(0);

}


 
Trader Mike:

Here is the deinit().  Could this be the problem?


int deinit()

{

ObjectsDeleteAll(0, 23);

    for(int a = ObjectsTotal();  a >= 0;  a--)

    {

        string name = ObjectName(a);

        if(ObjectType(name) == OBJ_TREND && (StringFind(name,"DP_Line") >= 0 ||

        StringFind(name,"SW_Line") >= 0))

            ObjectDelete(name);

    }

    

return(0);

}


When posting code, use the CODE button (Alt+S)! 
 
Trader Mike:
Try to give all objects a common prefix and get by with a single call to ObjectsDeleteAll()
#define OBJ_NAME_PREFIX "Mike_"

int OnInit()
  {
   string dpLinePrefix = OBJ_NAME_PREFIX + "DP_Line";
   string swLinePrefix = OBJ_NAME_PREFIX + "SW_Line";
   //...
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0, OBJ_NAME_PREFIX, EMPTY, EMPTY);
  }
 
I'm afraid that didn't work either.  But here's a new wrinkle:  It ONLY happens on the USTEC100 chart (CFD for NASDAQ) of Ox Securities!  The other symbols don't have the problem!  Weird!
 
With Comment("..") let it show what is deleted, then you can see how fast and what is deleted and maybe where it hangs. 
(That's the ABCs of programming.)
 

I tried the Comment() idea - and now it works!  Meaning, it will properly delete the lines I need it to delete and doesn't freeze the platform.  I really have no idea what is going on.  It might have problems again tomorrow/  But thanks for your help.