Select Object from variety

 
I have five HLine Objects and I would like to automatically select the one that is closest to the bid price. is it even possible?
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long id=ChartID();
   string name,minname;
   double diff,mindiff=SHORT_MAX,bid=SymbolInfoDouble(_Symbol,SYMBOL_BID),price=0,minprice=0;
   for(int i=0;i<ObjectsTotal(ChartID(),0,OBJ_HLINE);i++)
     {
      name=ObjectName(id,i,0,OBJ_HLINE);
      if((diff=MathAbs(bid-(price=ObjectGetDouble(id,name,OBJPROP_PRICE))))<mindiff)
        {
         mindiff=diff;
         minname=name;
         minprice=price;
        }
     }
//---
   Comment(minname," @ ",DoubleToString(minprice,_Digits)," is closest to ",DoubleToString(bid,_Digits));
  }
//+------------------------------------------------------------------+