Get the Chart ID for the 2 other charts with the buttons. Send the custom event.
my question is how can I understand the buttons on the other pages have pressed ?
you know, I want to do this throu event , not by checking State of the buttons ( pressed or not ) on the other page
I have saved 3 pages 's ID .
I only have run one expert on first page
my question is how can I understand the buttons on the other pages have pressed ?
you know, I want to do this throu event , not by checking State of the buttons ( pressed or not ) on the other page
I have saved 3 pages 's ID .
I only have run one expert on first page
Example in the documentation for the EventChartCustom does just what you want - it detects button click on the chart and then based on the button state it broadcasts an event.
The key point is to define different events for different button states.
Study that code.
Example in the documentation for the EventChartCustom does just what you want - it detects button click on the chart and then based on the button state it broadcasts an event.
The key point is to define different events for different button states.
Study that code.
there is a difference
the button in the example is located in the chart that the expert is attached .
but mine is in another page !!
<<>>>>how can I detect mouse click on another chart's button or other objects ?<<<>>>>
there is a difference
the button in the example is located in the chart that the expert is attached .
but mine is in another page !!
<<>>>>how can I detect mouse click on another chart's button or other objects ?<<<>>>>
Read the sample code, especially the last function - "BroadcastEvent" - it broadcasts event to all active charts.
After that, study OnChartEvent function in the sample code and carefully examine part where it catches CHARTEVENT_CUSTOM.
Is there anything that prevents you from creating two EA's or indicators where one of them broadcasts event and another waits for it?
Simplest test - compile that sample code and run it on two charts and then click on one chart and check what happens on another.
Is there anything that prevents you from creating two EA's or indicators where one of them broadcasts event and another waits for it?
Simplest test - compile that sample code and run it on two charts and then click on one chart and check what happens on another.
OK thank you very much
I want to simplify running the expert .
then as you say the optimum way is to write an indicator and load on the other charts to send the event to master chart (expert) or do the task by itself.
am I right?
OK thank you very much
I want to simplify running the expert .
then as you say the optimum way is to write an indicator and load on the other charts to send the event to master chart (expert) or do the task by itself.
am I right?
I really don't know what you want to achieve. I just pointed out that the sample code from the documentation does what you asked in your original question - put a button on a chart, then broadcast the click to all active charts, and then listen to the broadcasted event on all charts where the sample EA runs.
The part of the code from the sample that detects a button click and then broadcasts events should be on all charts where you want a button
The part of the event handler from the sample code that waits for the CHARTEVENT_CUSTOM should be on all charts where you want to listen for the event.
Both parts of that code can work both in EA and indicator, so the architecture depends on what you want to accomplish.
Sample code has both parts because it was simpler to have both broadcast and event listen code in a single file.
Anyway - did you try what I suggested before - compile the sample code, run it on two or more charts, and then click the button? Do you understand how it works? Run one copy from the debugger and go through the code.
The answers are above. Just as a sample
#define Click_But1 14 // Button 1 #define Click_But2 15 // Button 2 #define Click_But3 16 // Button 3 if(id==CHARTEVENT_OBJECT_CLICK) { //--- divide the object name by separator string obj_name[]; StringSplit(sparam, '_', obj_name); //--- check if the object is a button //... //--- Broadcasting events to the required chart long IDs[2]; EventChartCustom(IDs[0], Click_But2, lparam, dpar am, sparam); EventChartCustom(IDs[1], Click_But3, lparam, dparam, sparam); } if(id==CHARTEVENT_CUSTOM+Click_But2) { // Carry out Button 2 action }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I have created 3 button in three diferent chart, with one expert !
and now I want to do something when the buttons get pressed by mouse click
it is simple for the button that is in chart that the expert is athached , using this code :
but for two buttons in other charts I canot do something !
I guess it is possible with EventChartCustom function because it has : long chart_id, parameter , but I can not understand how by reading the help !!
can anyone guide me please ?
regards