Help needed and appreciated. Problem in using Button in Expert Advisor

 
void BreakOut()
{
//--- Create a button to send custom events
   ObjectCreate(0,buttonID,OBJ_BUTTON,0,100,100);
   ObjectSetInteger(0,buttonID,OBJPROP_COLOR,clrWhite);
   ObjectSetInteger(0,buttonID,OBJPROP_BGCOLOR,clrGray);
   ObjectSetInteger(0,buttonID,OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,buttonID,OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0,buttonID,OBJPROP_XSIZE,200);
   ObjectSetInteger(0,buttonID,OBJPROP_YSIZE,50);
   ObjectSetString(0,buttonID,OBJPROP_FONT,"");
   ObjectSetString(0,buttonID,OBJPROP_TEXT,"Activate");
   ObjectSetInteger(0,buttonID,OBJPROP_FONTSIZE,10);
   ObjectSetInteger(0,buttonID,OBJPROP_SELECTABLE,0);
   return;
}

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
      if(sparam==buttonID) // Activation Button
        {
         Print("Button Pressed");
         Action_Button();
         ObjectSetInteger(0,buttonID,OBJPROP_STATE,false);
        }
}
void Action_Button()
{
    Print("Button Pressed Subroutine");
    ExpertActive=true;
    ObjectDelete(0,buttonID);
}
 
hhemmat:

I Don't know why Expert doesn't delete the button.

Please someone help me find why

 

You have to pass the ID to the function otherwise it won't know what button

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
      if(sparam==buttonID) // Activation Button
        {
         Print("Button Pressed");
         Action_Button(buttonID);
         ObjectSetInteger(0,buttonID,OBJPROP_STATE,false);
        }
}
void Action_Button(string buttonID)
{
    Print("Button Pressed Subroutine");
    ExpertActive=true;
    ObjectDelete(0,buttonID);
}
Reason: