ObjectDelete

 

Hi guys, on my costom indicator I draw a lot of hline bye this line code:

if(!ObjectCreate(ChartID(),Obj_Name,OBJ_TREND,0,time[i],TG,time[i-1],TG)){

         Qnt_Symb=FileWrite(FileOUT,"Errore creazione oggetto getlasterror ", GetLastError());

         }

     ObjectSetInteger(ChartID(),Obj_Name,OBJPROP_COLOR,Colore); 

     ObjectSetInteger(ChartID(),Obj_Name,OBJPROP_STYLE,Stile);

All these line are hline starting on time[i]. 

Now I want delete all line < price[x] and > price[y]

Can someone of you help my with a good idea?

Tank for every help

Fabio

 
80613536:

Hi guys, on my costom indicator I draw a lot of hline bye this line code:

if(!ObjectCreate(ChartID(),Obj_Name,OBJ_TREND,0,time[i],TG,time[i-1],TG)){

         Qnt_Symb=FileWrite(FileOUT,"Errore creazione oggetto getlasterror ", GetLastError());

         }

     ObjectSetInteger(ChartID(),Obj_Name,OBJPROP_COLOR,Colore); 

     ObjectSetInteger(ChartID(),Obj_Name,OBJPROP_STYLE,Stile);

All these line are hline starting on time[i]. 

Now I want delete all line < price[x] and > price[y]

Can someone of you help my with a good idea?

Tank for every help

Fabio

OBJ_TREND is not hline  

if they are horizontal trend lines then just create a loop, go through the objects, test the price criteria and delete 

 
RemoveObjects(price[x], price[y]);

void RemoveObjects(double minPrice, double maxPrice) {
   for(int i = ObjectsTotal(); i >= 0; i--) {
      string   name  =  ObjectName(i);
      double   price =  ObjectGetDouble(0, name, OBJPROP_PRICE);
      
      if(price < minPrice || price > maxPrice) {
         ObjectDelete(name);
      }
   }
}
Reason: