Delete HLINE

Yango
204
hello, i am facing a problem. as soon as the last executed trade runs into loss (SL hit), an arrow_stop is placed on the chart. the SL is placed at the price of a HLINE (temp_green_down). as soon as the arrow_stop appears on the chart, the prices of the lines are assigned with the double values "Delete_Green_Line_Up" and "Delete_Green_Line_Down", which are globally initialized with "0". then a for-loop runs through all objects and is supposed to delete these two lines Delete_Green_Line_Up and Delete_Green_Line_Down, at the respective prices. temp_green_up and temp_green-down are also double values... the prices all fit, have it displayed 10000 times. the problem: Delete_Green_Line_Down can be deleted. but as soon as i want to delete Delete_Green_Line_Up, all lines on the chart disappear and it gets into a continuous loop. can not find the error... 

Translated with www.DeepL.com/Translator (free version)
double Delete_Green_Line_Up     = 0;
double Delete_Green_Line_Down   = 0;
double MyPrice = DoubleToString(HistoryDealGetDouble(HistoryDealGetTicket(HistoryDealsTotal()-1),DEAL_PROFIT),_Digits);

if( MyPrice < 0 && (Delete_Green_Line_Up   == 0) && (Delete_Green_Line_Down == 0) ){
       ENUM_TIMEFRAMES Timeframe = PERIOD_CURRENT;       
       datetime time = iTime(_Symbol,Timeframe,0);
       datetime signalTime = time+(SECONDS_PER_MINUTE*200);
       string name = "Trade this zone no more.. "+TimeToString(signalTime);

       ObjectCreate(_Symbol,name,OBJ_ARROW_STOP,0,signalTime,temp_green_up );
       ObjectSetInteger(WINDOW_MAIN,name,OBJPROP_COLOR,clrWhite);
       
       Delete_Green_Line_Up   = temp_green_up;
       Delete_Green_Line_Down = temp_green_down;       
       }


if( ObjectsTotal(ChartID(),0,OBJ_ARROW_STOP) > 0 ){
for (int i = ObjectsTotal(ChartID(),0,-1)-1; i>=0; i--){
  string objects_lines = ObjectName(ChartID(), i); 
  if (  ObjectGetInteger(ChartID(), objects_lines, OBJPROP_TYPE) != OBJ_HLINE) continue; 
  if ( (ObjectGetInteger(ChartID(), objects_lines, OBJPROP_TYPE) == OBJ_HLINE) && (ObjectGetDouble(ChartID(), objects_lines, OBJPROP_PRICE) == Delete_Green_Line_Down) ) {  
        PrintFormat(ObjectDelete(0,objects_lines)); 
        }
    }
}