This will delete an indicator given its handle.
bool pChartIndicatorDelete(int &indicator_handle) { // CHART_WINDOWS_TOTAL // The total number of chart windows, including indicator sub_windows long num_windows=ChartGetInteger(chart_ID,CHART_WINDOWS_TOTAL); // Loop backwards in case deleting for ( int window = (int) num_windows -1; window>-1; window-- ) { int numIndicators = ChartIndicatorsTotal(chart_ID,window); for(int index=0; index<numIndicators; index++) { // This indicator's name string name = ChartIndicatorName(chart_ID,window,index); // Get this indicator's handle for comparison int handle=ChartIndicatorGet(chart_ID,window,name); if ( handle == indicator_handle ) { if(!ChartIndicatorDelete(chart_ID,window,name)) { PrintFormat("Error indicator delete. Error: %d", GetLastError() ); return false; } else { IndicatorRelease(indicator_handle); //indicator_handle=INVALID_HANDLE; return true; } } } } return false; }
It would be much better if I can change the period property of the indicator, is there a way to do that in this case?
I don't think so.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In mql5, after adding an indicator to the chart in the code of an expert advisor using the function
ChartIndicatorAdd(0,0,ind_handle)
.
Now I like to change the indicator period. is there a way to do this or I have to delete the indicator and re-add it with the new period?
and if so, how can I delete it without having a name since ChartIndicatorDelete 3rd argument is the indicator_shortname
ChartIndicatorDelete(0,0,indicator_shortname)
which there is no mql5 function to add a short name after using ChartIndicatorAdd().
And AFAIK indicator_handle is not the same as indicator_shortname.
Thanks