React to a button clicked inside another chart

 

Hi,

I want to ask you if it is possible to react to a button clicked from a chart that is opened from the main chart which the EA is executed on.

I load the EA in the main chart. In this main chart, under some circumstances another chart is opened.

Inside this new chart, the EA creates a button. And the click actions of this button are what I want to intercept in the original EA. Is this possible to achieve?

(When the new chart is created, the EA knows its ID. Also knows the NAME of the new button).

thanks!

 

 
Jose Luis Lominchar:

I want to ask you if it is possible to react to a button clicked from a chart that is opened from the main chart which the EA is executed on.

I load the EA in the main chart. In this main chart, under some circumstances another chart is opened.

Inside this new chart, the EA creates a button. And the click actions of this button are what I want to intercept in the original EA. Is this possible to achieve?

(When the new chart is created, the EA knows its ID. Also knows the NAME of the new button).

I doubt so. One possible way is to use ChartApplyTemplate() and assign one with a special indicator on the second chart, which will then capture button click and somehow communicate this action back to the original EA.

 

Yes you can specify the chartID when you call for the OBJPROP_STATE of the button.

It is the first Parameter of the function ObjectGetInteger(chartID,...

 
Thanks, I will try those tips.
 

In graph 0 I have the EA. In others graphs I don’t have EAs, just buttons. But in the EA I know the others numGraphs and someBtnNames..

As Marco vd Heijden suggested I achieve it with the following inside onTick method of my EA:


bool btnPressed = ObjectGetInteger(numGraph, someBtnName, OBJPROP_STATE);
Reason: