"MCM Control Panel" for Multi-Currency Expert Advisors and Indicators - Expert for MetaTrader 5













One of the advantages of the MQL5 language is the possibility to use multi-currency indicators and Expert Advisors. Look at the multi-currency OnTickMarketWatch tick event handler in the MQL5 code base .
It is not convenient to use the concepts presented in the script. For example, in the case of many events, it is possible that the event queue overflows.
This is the comment from MQL5 reference :
The client adds occurrence events to the event queue. So events are processed one after another in the order they are received. There is an exception for the NewTick event. If the queue already has such an event or this event is being processed, the new NewTick event is not enqueued.
The event queue is limited in size. When the queue overflows, old events are deleted without processing to allow new events to be received. Therefore, it is recommended to write efficient event handlers and using infinite loops is not recommended (with one exception for scripts, which handle only the start event).
Furthermore, sometimes the indicator value needs to be recalculated only when a new bar appears. Another case is if you need to disable "instant" trading of certain symbols in a multi-currency Expert Advisor, to change the time frame of certain symbols or something else.
"Something else" might be external data. The MCM (Multi-Currency Mode) control panel is based on this idea.
By the way, it can also be used for single currency transactions.
"MCM Control Panel" (Competition Edition) has the following features:
It has the minimum functionality required to use multi-currency mode in Expert Advisors and indicators:
Using the MCM Control Panel you can add your own functionality. See below for details.
Saving/restoring control panel settings is not supported in this release.
There are several ways to launch MCM Control Panel:
In the third case, the panel will load our Expert Advisor or indicator and attach it to the chart.
Your Expert Advisor should have OnChartEvent() event handler to handle MCM control panel events.
The user interface is simple, it is implemented as a menu. The size and color of the menu can be configured via input parameters.
It looks like this:

This panel is used to configure events for multi-currency EA transactions and indicators.
The size and position of the panel depends on the chart size and font size (defined in the input parameters). To free up work space, panels can be minimized.

The size of the panel can be changed by changing the font size in the input parameter (font size = 10 by default):

You can set any color you want.
For example, pink scheme:

EMO plan:

The menu is intuitive and easy to use.
The MCM Control Panel button contains additional functionality (not included in this release):

Using the "Chart" button you can easily change the current symbol and timeframe, just select it:

"Events" allows you to enable/disable events for certain symbols "on the fly" (without restarting the Expert Advisor or indicator) and specify the required events. These events can be handled within the OnChartEvent() function of the Expert Advisor or Indicator. The symbol menu only contains symbols selected from Market Watch. You can combine any events and all will be processed.
For example, don't worry about the appearance of a new price tick/bar on a symbol on a timeframe, the panel engine will send the event:

Here's the "help":

Know-how and its implementation
My solution was posted on Multi-CurrencyOnTickMarketWatch Tick Event Handler , but the panel has some additional features:
Information about events and alerts
The panel has a status bar to display events.
Installation of MCM control panel
Extract the archive file mcm_control_panel.zip to the client folder. The following files will then appear:
Next, compile indicators, scripts and Expert Advisor.
Launch the MCM control panel
The launch of MCM Control Panel attaches the iControl panel MCM.mq5 indicator to any chart.
The panel can be launched from an Expert Advisor by simply attaching the "exControl panel MCM" Expert Advisor to the chart:

As a multi-currency example, I wrote the MultiTrend Expert Advisor. This indicator plots the USD trend based on the analysis of 4 currency pairs:
Here is the code:
//+------------------------------------------------------------------+ //| Multitrend.mq5 | //| Copyright 2010, Liza | //| https://www.mql5.com/ru/users/Lizar | //+------------------------------------------------------------------+ #Define version "1.00 version 2 (December 9, 2010)" #propertycopyright "Copyright 2010, Lizal" #Attribute link "https://www.mql5.com/ru/users/Lizar" #Attribute version version #Attribute description "This EA transaction uses the MCM control panel" Input color background color = gray ; // menu color input color font color = gainsborough ; // text color input color select color = yellow ; // selected text color Input integer font size = 10 ; // font size #include <Control PanelMCM.mqh> //<--- include files //+------------------------------------------------------------------+ //|Expert initialization function | //+------------------------------------------------------------------+ Integer initialization () { //--- MCM control panel initialization. //--- No need to set the color, if not specified, the default color will be used. InitControlPanelMCM(bg_color,font_color,select_color,font_size); //--- Return ( 0 ); } //+------------------------------------------------------------------+ //|Expert to initialize function | //+------------------------------------------------------------------+ Blank solution initialization ( constant integer reason) { DeinitControlPanelMCM(); //<--- MCM control panel deinitialization } //+------------------------------------------------------------------+ //| OnChartEvent event handler. | //|For more information, see the MQL5 Reference. | //|Can be used with MCM control panel for multi-currency trading| //+------------------------------------------------------------------+ Blank chart event ( constant integer ID, // event identifier: // if id-CHARTEVENT_CUSTOM==0 - initialization event (when prev_calculated==0) // if id-CHARTEVENT_CUSTOM!=0 - symbol index in the "Market Watch" window constant long & lparam, // roughly time constant double &d parameter, // price constant string & spam // symbol ) { if (id>= CHARTEVENT_CUSTOM ) { print ( String time ( timecurrent (),TIME_SECONDS), "-> id="" , ID- CHARTEVENT_CUSTOM , ":" ,Spam,lass="string">" ", event description (lparam), "price=" , d parameter); } } //+------------------------------------------------------------------+
OnChartEvent() parameters.
The control panel generates custom events. These events can be handled in the Expert Advisor or indicator using the OnChartEvent() event handler.
Input parameters:
List of supported events in MCM control panel
Using the lparam parameter, the control panel can send up to 64 different custom events on the symbol. The following events are supported in this release:
The event description returned by EventDescription() is shown in parentheses (initialization, tick, Mxx, etc.). The EventDescription function can be found in the control panel MCM.mqh (after the ENUM_CHART_EVENT_SYMBOL enumeration).
The "initialization" event is generated when prev_calculated=0 and can be used to prepare data, for example to recalculate indicator values.
To set the desired event, click the "Event" button, select the symbol and event type. Selected events are displayed in yellow (or the selected color in the indicator input parameters). You can select one or multiple events, all of which can be handled by our multi-currency Expert Advisor. To apply changes, click the Enable/Disable Events button.
The same process can be performed for all necessary symbols.

Here is the log from the Experts tab:

Attachment download
Source: MQL5 #215
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •