Download MetaTrader 5

Controlling the display of a indicator

To add comments, please log in or register
John May
3819
John May  
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);			
     }
John May
3819
John May  
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

Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
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.
phi nuts
2181
phi nuts  
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

To add comments, please log in or register