Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ChartEvent Test Example - MetaTrader 4 Expert | MT5 EA Download - MetaTrader 5 Resources

author EAcpu | 3 reads | 0 comments |

ChartEvent Test Example - expert for MetaTrader 4

The "Test_ChartEvent.mq4" Expert Advisor is an example demonstrating various types of ChartEvents: keyboard key events, mouse click and movement events, custom events. You can press the "H" key for help and then the "M" key to enter MOUSE_MOVE event mode.

The source code is available for MetaTrader 4 and MetaTrader 5.

Three types of custom events are defined:

This function creates a custom ChartEvent periodically. This function randomly generates these three custom events (cMyEvent_1, cMyEvent_2, and cMyEvent_3_broadcast). In particular, the cMyEvent_3_broadcast event is generated for all open chart windows.

The "CObjectMan" class was created to handle the functionality of objects on charts. Two instances (variables) of this class are declared: gObjectMan1 and gObjectMan2.

The names of the graphic objects linked to these two instances are: "Green Button" and "Yellow Button".

Invalid OnChartEvent():

"CHARTEVENT_KEYDOWN" event:

Print information about these events. Especially for the MyEvent_3_broadcast event.

ChartEvent Test Example - expert for MetaTrader 4

You can perform the following tests:


Attachment download

📎 test_chartevent.mq4 (20.35 KB)

Source: MQL5 #17875

Verification code Refresh