How to delete OBJ_TEXT by int deinit() ?

 
int start()

{

.

.

ObjectCreate ("Point"+Time[i],OBJ_TEXT,0,Time[i],Close[i]);

ObjectSet("Point"+Time[i], OBJPROP_TIMEFRAMES, OBJ_PERIOD_H4);

ObjectSetText("Point"+Time[i],"Cross"+Close[i], 10, "Times New Roman", White);

return(0);

}


int deinit()

{

ObjectsDeleteAll(0,OBJ_TEXT); // It will delete all OBJ_TEXT include another indicators too.

return(0);

}

How to delete only OBJ_TEXT "Point"+Time[i] name ?


Thank you

 
ObjectDelete()
 
int deinit()
{
//----
int counted_bars1=IndicatorCounted();
int limit1;
if (counted_bars1>0) counted_bars1--;
limit1=Bars-counted_bars1;
if(limit1>100) limit1=100;
for (int ii=0;ii<limit1;ii++) {ObjectDelete("Point"+Time[ii]);}
//----
return(0);

}

Nothing happen.

 
// global Variable for all Obj of this Indicator or EA: ObjectCreate(idObj+"..", ..);
string idObj = "Point";
...
int deinit()
  {
        string sID; 
        int t = ObjectsTotal(); // or ObjectsTotal(OBJ_TEXT);
        while (t>0) {
                t--;
                sID = ObjectName(i);
                if ( StringFind( sID, idObj ) != -1 ) {
                        ObjectDelete( sID );
                }
        } 
        return(0);
  }
 
gooly:


Thank you.

But not work.

Because my object text name follow by time[i].
 
sorasit46:

<CODE DELETED>

How to delete only OBJ_TEXT "Point"+Time[i] name ?

Thank you

You have been asked before . . .


Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

 
sorasit46:

Thank you.

But not work.

Because my object text name follow by time[i].
Loop through all the Objects, if they are of type OBJ_TEXT and the name contains "Point" delete . . .
 
RaptorUK:
Loop through all the Objects, if they are of type OBJ_TEXT and the name contains "Point" delete . . .


Clue:
StringSubstr( string text, int start, int length=0)
 
#define ONDA_BEGINS     0
#define ONDA_CONTAINS   1
void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(type != EMPTY) if( type != ObjectType(on) )  continue;
      if(name != ""){
         int   iPos  = StringFind(on, name);
         if (iPos < 0)                             continue;
         if (iPos > 0 && where == ONDA_BEGINS)     continue;
      }
      ObjectDelete(on);
   }
}
int deinit(){
   ObjectNameDeleteAll("Point", ONDA_BEGINS, OBJ_TEXT);
 
WHRoeder:


Do you really think that the OP will be able to understand that?
 
This forum is about coding. He should, especially when I gave him the call.
Reason: