Цикл удаления объектов

 

Я пытаюсь удалить все горизонтальные линии, созданные по следующим критериям: Цена - это значение бара открытия и закрытия. В этом диапазоне значений может быть более одной строки. Может кто поможет исправить код.

#property indicator_chart_window
#property indicator_plots 0
double Open1,Open2,Close1,Close2;

   
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])                             
  { 
    
      Open1 =iOpen (_Symbol,PERIOD_M1,1);
      Open2 =iOpen (_Symbol,PERIOD_M1,2);
      Close1=iClose(_Symbol,PERIOD_M1,1);
      Close2=iClose(_Symbol,PERIOD_M1,2);
     
    
  //+------------------------------------------------------------------+
 //| DELETE LINES                                                      |
 //+------------------------------------------------------------------+
  
      if (Open1 <= Close1)        
       for (double i=Open1; i <= Close1; i++)
       {ObjectDelete(0,"HighGap="+DoubleToString(i,2));  
       Comment("HighGap="+DoubleToString(i,2));}
    
      else
      if (Open1 >= Close1)
      for (double i=Close1; i <= Open1; i++)
      {ObjectDelete(0,"LowGap="+DoubleToString(i,2));  
      Comment("LowGap="+DoubleToString(i,2));}
//+-------------------------------------------------------------------+
 //| CREATE LINES                                                     |
 //+------------------------------------------------------------------+  
   
            if (Open1>Close1 && Open1<Close2)   
                   {
                     CriarLinhaH(0,0,"LowGap="+DoubleToString(Open1),Open1,clrOrange,STYLE_DOT,1,true,false,true,"Low");
                   }
    else
            if (Open1<Close1 && Open1>Close2)     
                   {
                     CriarLinhaH(0,0,"HighGap="+DoubleToString(Open1),Open1,clrBlue,STYLE_DOT,1,true,false,true,"High");
                   }
                               
    return(rates_total);     
  }
  
 //+------------------------------------------------------------------+
 //| CODE FOR THE CREATION OF HORIZONTAL LINES:                     |
 //+-------------------------------------------------------------------+
 
void CriarLinhaH(const long janela,
                 const int subjanela,
                 const string nome,
                 double preco,
                 color cor,
                 const ENUM_LINE_STYLE estilo,
                 const int tamanho,
                 const bool oculto,
                 const bool fundo,
                 bool selecionavel,
                 string dica_=NULL)
  {
    if (ObjectFind(janela,nome)==-1)
    ObjectCreate(janela,nome,OBJ_HLINE,subjanela,0,preco);
    ObjectSetDouble(janela,nome,OBJPROP_PRICE,preco);
    ObjectSetInteger(janela,nome,OBJPROP_COLOR,cor);
    ObjectSetInteger(janela,nome,OBJPROP_STYLE,estilo);
    ObjectSetInteger(janela,nome,OBJPROP_WIDTH,tamanho);
    ObjectSetInteger(janela,nome,OBJPROP_HIDDEN,oculto);
    ObjectSetInteger(janela,nome,OBJPROP_BACK,fundo);
    ObjectSetInteger(janela,nome,OBJPROP_SELECTABLE,selecionavel);
    ObjectSetString(janela,nome,OBJPROP_TOOLTIP,dica_);
  }
Буду очень признательна!

 
long handle = ChartID();
if(ObjectFind(handle,"L123") == true)ObjectDelete(handle ,"L123");
Причина обращения: