Download MetaTrader 5

How to detect changes to indicator's parameters in EA?

To add comments, please log in or register
ale
76
ale  

Is it possible inside an EA to detect that the user has changed the parameters of one of the indicators?

My current solution is to embed the parameters in the short name of the indicator and then check every second inside OnTimer(). Is there a better way to detect changes to the indicator parameters?

Alain Verleyen
Moderator
36714
Alain Verleyen  
ale:

Is it possible inside an EA to detect that the user has changed the parameters of one of the indicators?

My current solution is to embed the parameters in the short name of the indicator and then check every second inside OnTimer(). Is there a better way to detect changes to the indicator parameters?

A CHARTEVENT_CHART_CHANGE event is triggered when you changed indicator's parameters.
ale
76
ale  
angevoyageur:
A CHARTEVENT_CHART_CHANGE event is triggered when you changed indicator's parameters.
Thanks! The MQL4 has no documentation for CHARTEVENT_CHART_CHANGE, but your comment led me to the MQL5 docs.
Anthony Garot
805
Anthony Garot  
Alain Verleyen:
A CHARTEVENT_CHART_CHANGE event is triggered when you changed indicator's parameters.

Is it possible to tell the difference between a chart resize and a change to the indicator's parameters?

The documentation says, "Change of the chart size or modification of chart properties through the Properties dialog."

It does, indeed, fire for either case; but I see no immediate way to tell them apart. The lparam, dparam, and sparam seem to be the same for either size change or properties modification.

Alain Verleyen
Moderator
36714
Alain Verleyen  
Anthony Garot:

Is it possible to tell the difference between a chart resize and a change to the indicator's parameters?

The documentation says, "Change of the chart size or modification of chart properties through the Properties dialog."

It does, indeed, fire for either case; but I see no immediate way to tell them apart. The lparam, dparam, and sparam seem to be the same for either size change or properties modification.

Unfortunately CHARTEVENT_CHART_CHANGE is a catchall event. So you need to test for the changes you want to process.
Anthony Garot
805
Anthony Garot  
Alain Verleyen:
Unfortunately CHARTEVENT_CHART_CHANGE is a catchall event. So you need to test for the changes you want to process.
Roger that. Thank you for your response.
Lakshan Perera
3301
Lakshan Perera  
Anthony Garot:

Is it possible to tell the difference between a chart resize and a change to the indicator's parameters?

The documentation says, "Change of the chart size or modification of chart properties through the Properties dialog."

It does, indeed, fire for either case; but I see no immediate way to tell them apart. The lparam, dparam, and sparam seem to be the same for either size change or properties modification.

You can use the reason code of the OnDeinit() as well

void OnDeinit(const int reason)
  {
   if(reason == REASON_PARAMETERS)
     {
      //Parameters Changed
     }
  }

but it will also trigger even if you open the input dialog box and click OK without even changing the parameters..

Alain Verleyen
Moderator
36714
Alain Verleyen  
Lakshan Perera:

You can use the reason code of the OnDeinit() as well

but it will also trigger even if you open the input dialog box and click OK without even changing the parameters..

You missed the point I think, the goal is to detect a change OUTSIDE the indicator.
Lakshan Perera
3301
Lakshan Perera  
Alain Verleyen:
You missed the point I think, the goal is to detect a change OUTSIDE the indicator.

what do you mean? maybe I have misread the question, can you please elaborate more?

nicholi shen
1699
nicholi shen  
Anthony Garot:
Roger that. Thank you for your response.

You could save the chart template and then parse the tpl.xml file in order to find which params have changed is any. 

Anthony Garot
805
Anthony Garot  
nicholi shen:

You could save the chart template and then parse the tpl.xml file in order to find which params have changed is any. 

That seems like a good general solution.

For my current need, I found an easy enough work-around.

I did ask the Service Desk if they would consider differentiating between the two events. I suggested a non-zero value for lparam.

To add comments, please log in or register