Download MetaTrader 5
To add comments, please log in or register
What is the best place to find a programmer? Freelance service!
John May
3687
John May 2013.02.23 19:37 
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
3687
John May 2013.02.23 19:38  
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
17972
Simon Gniadkowski 2013.02.24 15:41  
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
2184
phi nuts 2013.02.25 04:58  
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