How to Move & Replace text (Objects/Label) from the chart

 

Hello,


One of my indicators is printing text not good on the chart, I do not have the mq4 file for that indicator.




Can I move and replace text using another indicator?

I tried Object list, but not keep Also, this code did not work

ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   string obj_name = "Object";
   if(id==CHARTEVENT_OBJECT_CREATE && sparam==obj_name)
     {
  int replaced=StringReplace(obj_name,"text","new text");
  Print("Replaced: ", replaced,". Result=",obj_name);
     }
  }

I would appreciate any ideas?

 

Maybe the object is already created before you run this new indicator, but anyway using the StringReplace function here does not make sense. You should use ObjectSetString function:


   
 void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   string obj_name = "Object";
   if(id==CHARTEVENT_OBJECT_CREATE && sparam==obj_name)
     {
      ResetLastError(); 
      if(!ObjectSetString(0, obj_name, OBJPROP_TEXT, "new text"))
      PrintFormat("Unable to change: %s text. Error: %d", obj_name, GetLastError());
      else
      PrintFormat("%s text changed successfully", obj_name);
     }
  }
   
Reason: