Download MetaTrader 5

Action on all charts when a button is pressed in one chart

To add comments, please log in or register
jaya7838
17
jaya7838  

Hello there,

Can someone guide me on how to make an EA on each chart do something once when a button is pressed in any one of the charts in the same terminal? My guess is that I need to use Global Variables here. I am using MQL4 and not MQL5.

Thanks in advance.

Carl Schreiber
7295
Carl Schreiber  

Loop through all you chart with ChartFirst() and ChartNext() and the other function beginning with Chart..

Type e.g. ChartFirst() in the editor and press F1 - there you find everything you need.‌

honest_knave
Moderator
2326
honest_knave  
jaya7838:

Hello there,

Can someone guide me on how to make an EA on each chart do something once when a button is pressed in any one of the charts in the same terminal? My guess is that I need to use Global Variables here. I am using MQL4 and not MQL5.

Thanks in advance.


You can use GVs, but you could also use EventChartCustom() and broadcast the event to all charts.

E‌ach EA is listening for the custom chart event, and takes action accordingly.

T‌ake a look at the documentation, and this post may help too.

EventChartCustom - Working with Events - MQL4 Reference
EventChartCustom - Working with Events - MQL4 Reference
  • docs.mql4.com
EventChartCustom - Working with Events - MQL4 Reference
jaya7838
17
jaya7838  
Thank you both very much. I think I will write a separate script using ChartFirst() and ChartNext() to loop through the charts and do what I want, leaving the existing EA as it is. Once again, Thanks a lot
Mladen Rakic
61911
Mladen Rakic  
jaya7838:

Hello there,

Can someone guide me on how to make an EA on each chart do something once when a button is pressed in any one of the charts in the same terminal? My guess is that I need to use Global Variables here. I am using MQL4 and not MQL5.

Thanks in advance.

The code for both mt4 and mt5 will be exactly the same though

To add comments, please log in or register