SR Indicator not moving lines/labels correctly

 

I have been writing my own custom SR indicator and have one glaring problem I haven't been able to fix. At the rollover of a new day (and subsequent recalculation of Daily SR levels by the indicator) my SR lines all start drawing at 45 degree angles across the chart and the labels don't update their text. Here is an excerpt from my indicator that draws a SR line and prints the label below it.


      value = DoubleToStr( R1, 4 );
      
      if( ObjectFind("R1_Line") < 0 )
      {
         ObjectCreate("R1_Line", OBJ_TREND,0, Time[0], R1, Time[1], R1);
         ObjectSet("R1_Line", OBJPROP_COLOR, Orange);
         ObjectSet("R1_Line", OBJPROP_STYLE, STYLE_DOT);
      }
      else
      {
         ObjectMove("R1_Line", 0, Time[0], R1);
      }  

      if( ObjectFind("R1_Label") < 0 )
      {
         ObjectCreate("R1_Label", OBJ_TEXT, 0, Time[20], R1);
         ObjectSetText("R1_Label", "DR1" + " (" + value + ")", 8, "Verdana Bold", Black);
      }
      else
      {
         ObjectMove("R1_Label", 0, Time[20], R1);
      }


The problem can be temporarily fixed by opening the indicator window (CTRL+I) opening the indicator settings, pressing RESET and then OK - OR by re-compiling the indicator in MetaEditor. So if there was some way to make the indicator realize the day has changed and then reset itself automatically then that may fix the issue permanently.


Any help would be much appreciated although testing a fix only happens once a day =(

Reason: