Indicator to delete indicator

 

Just looking for some coding help.

I designate shortname for indicator I want to be able to delete:

int init()
  {

  IndicatorSetString(INDICATOR_SHORTNAME,"PA");

...

return(0);
  }

Then for the indicator that will be deleting the one above, code is below.

I assume all I should need to do is to drag the one below to navigator:

#property strict
void OnStart()
  {
  ChartIndicatorDelete(0,0,"PA");
  }

My understanding is this is all I need? Doesn't work though.

Note my coding sucks, I've just pieced this together from google, so hoping someone could check if I'm missing anything.

Thanks!

 

Per the documentation:

"Return Value - Returns true if the command has been added to chart queue, otherwise false. To get error details use the GetLastError() function."

So check your return value and see what the error is. You can view the example code for how that is done here:

https://docs.mql4.com/chart_operations/chartindicatordelete

 
ephemeral:

Just looking for some coding help.

I designate shortname for indicator I want to be able to delete:

Then for the indicator that will be deleting the one above, code is below.

I assume all I should need to do is to drag the one below to navigator:

My understanding is this is all I need? Doesn't work though.

Note my coding sucks, I've just pieced this together from google, so hoping someone could check if I'm missing anything.

Thanks!

I suppose you used the correct parameter sub_window in the ChartIndicatorDelete() function. In this case try to add ChartRedraw()

#property strict
void OnStart()
  {
  ChartIndicatorDelete(0,0,"PA");
  ChartRedraw();
  }
 
Petr Nosek:

I suppose you used the correct parameter sub_window in the ChartIndicatorDelete() function. In this case try to add ChartRedraw()

 
@Anthony Garot

How do I get the output of this to print somewhere? Sorry, I'm very new to this.

@Petr Nosek

Yep, parameters are correct. Active window, main chart. Tried adding that, didn't help.

I noticed terminal says the below when I try to run the indicator that removes:

"Expert '<indicatorname>' is not a custom indicator and will be removed" 
I'm confused why it's calling it an Expert, I put it in root/MQL4/Indicators
 
Your code isn't an indicator. It is either an Expert or a Script. You have to insert this code into /MQL4/Experts or /MQL4/Scripts and then compile and run.
Reason: