Deleting Objects/Label from chart

 

Hello,

One of the indicators I am using in my EA is printing text on the chart, is it possible to automatically remove such text ? I do not have the mq4 file for that indicator.

 

Any help is appreciated!

 regards,

salexes 

 
Either mark it (mause click) and press del or to see and to manage all press Ctrl+B on the chart.
 
Carl Schreiber:
Either mark it (mause click) and press del or to see and to manage all press Ctrl+B on the chart.
I want to automatically remove it when the expert advisor starts. 
 
Fix your indicator.
 
salexes:

I do not have the mq4 file for that indicator.

whroeder1:
Fix your indicator.
How do I do that without the mq4 of it?
 
You can't. Create another indicator or modify your EA, or remove your indicator.
 

Got it. 

Used one of your answers from another thread:

 

    for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
        string on = ObjectName(iObj);
        if (StringFind(on, "ccline") == 0)  ObjectDelete(on);
        }  

 Thank you.

 

If you want to automate the process, the best option is what whroeder1 suggests i.e. create a new indicator or modify the EA.

If you can't create a new indicator, the "least ugly" option is to recode your EA to delete ccline3 whenever it is created.

If ccline3 only gets created once per initialization, it shouldn't be too much of a problem.

But, if the indicator keeps trying to recreate ccline3 every tick, you're going to end up in a permanent battle between your EA and this indicator.

If you want to give it a go, add this to your OnInit():

ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);

Then add this (or merge it, if you are already using OnChartEvent in your EA):

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   string prefix = "ccline";
   if(id==CHARTEVENT_OBJECT_CREATE && StringSubstr(sparam,0,StringLen(prefix))==prefix)
     {
      ObjectDelete(0,sparam);
      Print("Deleted ",sparam);
     }
  }

 

I've added a print statement so you can see how frequently ccline3 is being deleted.

Check the Experts log to see how often ccline3 is being deleted. 

 
honest_knave:

If you want to automate the process, the best option is what whroeder1 suggests i.e. create a new indicator or modify the EA.

If you can't create a new indicator, the "least ugly" option is to recode your EA to delete ccline3 whenever it is created.

If ccline3 only gets created once per initialization, it shouldn't be too much of a problem.

But, if the indicator keeps trying to recreate ccline3 every tick, you're going to end up in a permanent battle between your EA and this indicator.

If you want to give it a go, add this to your OnInit():

ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);

Then add this (or merge it, if you are already using OnChartEvent in your EA):

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   string obj_name = "ccline3";
   if(id==CHARTEVENT_OBJECT_CREATE && sparam==obj_name)
     {
      ObjectDelete(0,obj_name);
      Print("Deleted ",obj_name);
     }
  }

I've added a print statement so you can see how frequently ccline3 is being deleted.

Check the Experts log to see how often ccline3 is being deleted. 

Thank you, this solution works perfect.
 
salexes:
Thank you, this solution works perfect.
I've modified my code above because I saw from your last post there are multiple objects with the prefix "ccline"
 
i want to delete the unwanted label and text from my template chart...3 indicators i am using with ex4 file (no mql4) they display unwanted text and label..plz guide me to hide or delete the labe;l only from chart template...