Controlling the display of a indicator

 
I am calling the TRIX indicator in an EA to calculate some values. The moving period can vary so I am calling it within a function and not within the OnInit() function. The issue I am having is every time the moving period changes, it adds a new indicator to the chart. Is there a way to either delete the old indicator or not display it at all. Here is the code I am using to call the indicator:
//--- apply the indicator and get its handle
   iTRIX_handle=iTriX(my_symbol,L_TRIX_timeframe,cycle,L_APPLIED_PRICE);
//--- check the availability of the indicator handle
   if(iTRIX_handle==INVALID_HANDLE)
     {
      //--- no handle obtained, print the error message into the log file, complete handling the error
      Print("Failed to get the TRIX indicator handle");
      return(0);
     }
//--- copy data from the indicator array to the iTRIX_mainbuf dynamic array for further work with them
   err7=CopyBuffer(iTRIX_handle,0,0,L_TRIX_depth,iTRIX_mainbuf);
//--- in case of errors, print the relevant error message into the log file and exit the function
   if(err7<0)
     {
      Print("Failed to copy data from the TRIX indicator buffer for symbol ",L_my_symbol);
      return(0);			
     }

            
 
CappinJack:
I am calling the TRIX indicator in an EA to calculate some values. The moving period can vary so I am calling it within a function and not within the OnInit() function. The issue I am having is every time the moving period changes, it adds a new indicator to the chart. Is there a way to either delete the old indicator or not display it at all. Here is the code I am using to call the indicator:

Here is what the chart looks like after running a while

 
CappinJack:

Here is what the chart looks like after running a while

Does this help ?  https://www.mql5.com/en/forum/7037
Hide indicator display on backtest MT5
Hide indicator display on backtest MT5
  • www.mql5.com
Hide indicator display on backtest MT5.
 
CappinJack:
I am calling the TRIX indicator in an EA to calculate some values. The moving period can vary so I am calling it within a function and not within the OnInit() function. The issue I am having is every time the moving period changes, it adds a new indicator to the chart. Is there a way to either delete the old indicator or not display it at all. Here is the code I am using to call the indicator:

When the MA period has change, new handle is created.

If you're using some Chart Operations in your EA, like using ChartIndicatorAdd, then maybe you should not using it or also should use ChartIndicatorDelete

Reason: