NotifyMe for MT5

131 0 2023-12-22

OverviewThe Expert Advisor sends notifications to a mobile phone, via e-mail or activates an audio alarm in case any changes are detected on the trading account: opening/closing positions, changing order and position parameters, balance or leverage.

Overview

The Expert Advisor sends notifications to a mobile phone, via e-mail or activates an audio alarm in case any changes are detected on the trading account: opening/closing positions, changing order and position parameters, balance or leverage. Also, the Expert Advisor can inform that Equity on the trading account has dropped below a specified value or Free Margin is small compared to Margin. The Expert Advisor does not trade, it only monitors your account and orders.


Launching the Expert Advisor

You should allow automated trading in your MetaTrader 5 terminal to let the operation of the Expert Advisor. To do this, enter Tools - Options - Expert Advisors tab and enable "Allow automated trading" parameter. To launch the Expert Advisor, right-click its name in the Navigator window and select "Attach to chart" or drag and drop it on the chart by mouse. The windows of the Expert Advisor's parameters will appear. Set the desired parameters and click OK.

The Expert Advisor can be attached to the chart of any financial instrument. Analysis of order and position parameters is performed after any trading operation, while checks for reaching critical Equity or Free Margin levels is performed after a new quote arrives. Therefore, it is recommended to launch the Expert Advisor on the symbol with frequently arriving quotes (for example, on one of the basic symbols: EURUSD, GBPUSD, USDCHF or USDJPY) in order to decrease notification delays. Chart's time frame does not matter.


Expert Advisor's Input Parameters

  • Push Notification Events - select what events you want to be notified of via your mobile terminal (No notifications - disabled, Only Open/Close position notifications - notifying only of opening/closing positions, All notifications - notifying of all events);

  • Push Notification Critical Equity Level - minimum Equity on a trading account in the deposit currency. When this value is reached, the notification is sent to the mobile terminal;

  • Push Notification Critical Margin Level - minimum Free Margin level compared to Margin in percentage values. When the level is reached, the notification is sent to the mobile terminal;

  • Critical Event Push Notify Interval - minimum time interval (in seconds) between adding information about Equity or Free Margin reaching a critical level to push messages.

  • Push Notification Interval - minimum time interval (in seconds) between messages sent to the mobile terminal;

  • Push Message Maximum Length - maximum length of a message sent to the mobile terminal;

  • Mail Notification Events - select what events you want to be notified of via e-mail (No notifications - disabled, Only Open/Close position notifications - notifying only of opening/closing positions, All notifications - notifying of all events);

  • Mail Notification Critical Equity Level - minimum Equity on a trading account in the deposit currency. When this value is reached, the notification is sent via e-mail;

  • Mail Notification Critical Margin Level - minimum Free Margin level compared to Margin in percentage values. When the level is reached the notification is sent via e-mail;

  • Critical Event Mail Notify Interval - minimum time interval (in seconds) between adding information about Equity or Free Margin reaching a critical level to an email;

  • Mail Notification Interval - minimum time interval (in seconds) between notifications sent via e-mail;

  • Sound Notification Events - select what events you want to be notified of by a sound alarm (No notifications - disabled, Only Open/Close position notifications - notifying only of opening/closing positions, All notifications - notifying of all events);

  • Sound Notification Critical Equity Level - minimum Equity on a trading account in the deposit currency. When this value is reached, a sound alarm is activated;

  • Sound Notification Critical Margin Level - minimum Free Margin level compared to Margin in percentage values. When the level is reached, a sound alarm is activated;

  • Critical Event Sound Notify Interval - minimum time interval (in seconds) between sound alarms indicating Equity or Free Margin reaching a critical level;

  • Sound Notification Interval - minimum time interval (in seconds) between sound alarms;

  • Sound File Name - sound alarm file name;

  • Use time in messages - time specified in messages sent to the mobile terminal or via e-mail (Server Time - trade server time, Local Time - time of the PC the Expert Advisor is running at);

  • Screen Information - display server and local time, as well as notification settings (Show, Hide).


Calculating Free Margin Level

As mentioned earlier, the Expert Advisor can notify of decreasing Free Margin compared to Margin. Let's examine calculation of Free Margin level in more details. In most cases (including MetaTrader 5 trading terminal), Margin value is defined considering Leverage provided by a broker. But the broker can change the leverage value at any time, and the Margin value also changes subsequently. Most often, the leverage value is not so critical for trading (unless trading is conducted in a risky manner using the maximum possible position volume). Therefore, this Expert Advisor calculates the Margin value without regard to the leverage. Free Margin level is defined as a ratio of Free Margin to Margin in percentage value.

Let's consider the following example. Suppose that 1 lot equals to 100 000 units of the base currency. Position at EURUSD is opened having the volume of 0.10 lots at the price of 1.3 USD per 1 EUR. For buying or selling 0.10 * 100 000 = 10 000 EUR, we will need 13 000 USD. This value is considered to be the Margin for the present Expert Advisor (though in most cases, a leverage is applied to that value, for example, if leverage is 1:100, then we will have 130 USD of Margin). If the deposit is equal to 1000 USD, Free Margin will be equal to 1000 - 130 = 870 USD after opening a position, while the Margin level will be calculated as 870 / 13 000 = 0.0669 or 6.69 %. If we set the Margin limit, at which notification is delivered, to 5%, the notification will be sent in case of Free Margin being equal to 0.05 * 13 000 = 650 USD or Equity comprising 650 + 130 = 780 USD.

Despite the apparent complexity of defining the Free Margin level, this method provided the most informative results in actual practice.


Sending Notifications to the Mobile Terminal

First of all, you should have mobile version of MetaTrader 4 or MetaTrader 5 terminal installed on your Android or iOS powered device to receive notifications. You can download MetaTrader 4 or MetaTrader 5 mobile terminal for Android, as well as MetaTrader 4 or MetaTrader 5 mobile terminal for iOS for free.

You should allow sending push notifications in MetaTrader 5 trading terminal, on which the Expert Advisor is to be launched. To do this, enter Tools – Options – Notifications tab and turn "Enable Push Notifications" parameter on. You should also specify your MetaQuotes_ID on this tab. It can be found on Messages tab of the mobile terminal.

"Push Notification Events" input parameter allows you to define types of events that are followed by sending notifications to your mobile terminal. When set to "All notifications", messages are sent if any of the following events occur: position opening or closing, changing open position's Stop Loss and Take Profit parameters, changing pending order parameters - Open price, Stop Loss and Take Profit, changing the account's balance or leverage. When it is set to "Only Open/Close position notifications", notifications are sent only when opening and closing positions. If "No notifications" is selected, notifications are not sent to the mobile terminal. This parameter does not affect sending notifications indicating Equity or Free Margin reaching a critical level.

"Push Notification Critical Equity Level" input parameter allows you to define a critical (minimum) equity (in deposit currency) followed by sending notifications to your mobile terminal. If set to 0, notifications of equity decrease are not sent to your mobile terminal.

"Push Notification Critical Margin Level" input parameter allows you to define a critical (minimum) free margin level (in percentage value) followed by sending notifications to your mobile terminal. If set to 0, notifications of free margin level are not sent to your mobile terminal.

Information about events on a trading account, as well as about reaching critical Equity or Free Margin levels is added to the message sent to the mobile terminal under certain conditions.

"Critical Event Push Notify Interval" parameter allows you to set the time interval (in seconds), after which information about reaching critical Equity or Free Margin level is added to the push message prepared for delivery.

"Push Notification Interval" input parameter allows you to set the minimum time interval (in seconds) between push notifications sent to the mobile terminal. The Expert Advisor will not send a new notification if less than specified time has passed since sending the previous one. It will save that notification instead. When the time specified in "Push Notification Interval" parameter passes since sending the previous notification, the Expert Advisor will send a message containing descriptions of all events accumulated by that time. There is a limitation (of push notifications service developed by MetaQuotes) on the number of sent messages per unit time: no more than two messages per second and no more than 10 messages per minute (if this limitation is violated, sending push notifications can be blocked by MetaQuotes). Therefore, it is not recommended to set very small values of "Push Notification Interval" parameter (especially in case of the events' high frequency on a trading account).

"Push Message Maximum Length" parameter allows you to set the maximum number of symbols in a message sent to the mobile terminal. If a message is longer, it is truncated down to the length specified in the parameter. The maximum permissible length of a push message is 255 characters. A message consists of two parts: account number with account owner's name (generated automatically) and a text description of an event generated by an Expert Advisor (its length is limited by "Push Message Maximum Length" parameter). In some cases, a message may become invisible in the mobile terminal if its length exceeds 255 characters. "Push Message Maximum Length" parameter value should be selected based on the length of the automatically added part of the message (account number and owner's name).


Sending Notifications Via E-Mail

To receive notifications via e-mail, you should allow sending emails in the settings of MetaTrader 5 trading terminal, at which the Expert Advisor is launched. To do this, enter Tools – Options – Email tab, turn Enable parameter on and specify your e-mail account and SMTP e-mail server parameters. E-mail account and SMTP mail server parameters should be specified on this tab.

Messages sent by the Expert Advisor via e-mail have subject "Account account_number notification". 

"Mail Notification Events" parameter allows you to define types of events followed by notifications via emails (similar to "Push Notification Events" parameter for notifications sent to the mobile terminal). This parameter does not affect sending notifications indicating Equity or Free Margin reaching a critical level.

"Mail Notification Critical Equity Level" input parameter allows you to define a critical (minimum) equity (in deposit currency) followed by sending notifications via e-mail. If set to 0, notifications of equity decrease are not sent via e-mail.

"Mail Notification Critical Margin" input parameter allows you to define a critical (minimum) free margin level (in percentage value) followed by sending notifications via e-mail. If set to 0, notifications of margin decrease are not sent via e-mail.

Information about events on a trading account, as well as about reaching critical Equity or Free Margin levels is added to the message sent via e-mail under certain conditions.

"Critical Event Mail Notify Interval" parameter allows you to set the time interval (in seconds), after which information about reaching critical Equity or Free Margin level is added to the email prepared for delivery.

"Mail Notification Interval" input parameter allows you to set the minimum time interval (in seconds) between notifications sent via e-mail. The Expert Advisor will not send a new notification if less than specified time has passed since sending the previous one. It will save that notification instead. When the time specified in "Mail Notification Interval" parameter passes since sending the previous notification, the Expert Advisor will send a message containing descriptions of all events accumulated by that time. Some e-mail servers perceive frequent emails as harmful actions. Therefore, it is not recommended to set too small values for "Mail Notification Interval" parameter.


Audio Alarm Notifications

"Sound Notification Events" parameter allows you to define types of events followed by sound alarm notifications (similar to "Push Notification Events" parameter for notification sent to the mobile terminal and "Mail Notification Events" for notifications sent via e-mail). This parameter does not affect sending notifications indicating Equity or Free Margin reaching a critical level.

"Sound Notification Critical Equity Level" input parameter allows you to define a critical (minimum) equity (in deposit currency) followed by sending sound alarm notifications. If set to 0, notifications of critical free margin level are not activated.

"Sound Notification Critical Margin Level" input parameter allows you to define a critical (minimum) equity (in percentage value) followed by sending sound alarm notifications. If set to 0, notifications of critical free margin level are not activated.

"Critical Event Sound Notify Interval" parameter allows you to set the time interval (in seconds), after which a sound alarm notifying of reaching critical Equity or Free Margin level is activated.

"Sound Notification Interval" input parameter allows you to set the minimum time interval (in seconds) between audio alarms.

"Sound File Name" input parameter allows you to set a sound alarm file name. A file in .wav format should be located in terminal_folder/sounds or its subdirectory.


Displaying the Data on Screen

If "Screen Information" input parameter is set to Show, information on server and local time, as well as conditions for each notification type are displayed in the upper left corner of the chart. If it is set to Hide, the data is not displayed. 

Examples of messages sent by the program:

  • Placing a pending order: 2013.08.13 12:43:29 EURUSD Buy Limit 0.10 Placed, Op: 1.33090, SL: 1.32980, TP: 1.33240, Comment: Test order;

  • Changing pending order parameters: 2013.08.13 12:44:37 EURUSD Sell Limit 0.10, Op: 1.33121 -> 1.33112, SL: 0.00000 -> 1.33000, TP: 0.00000 -> 1.33200, Comment: Test order;

  • Deleting a pending order: 2013.08.13 12:54:19 EURUSD Buy Limit 0.10 at 1.33092 deleted;

  • Opening position : 2013.08.13 12:45:32 EURUSD Buy 0.10 open at 1.33090, SL: 1.33000, TP: 1.33200;

  • Closing position: 2013.08.13 12:48:42 EURUSD Buy 0.10 closed at 1.33111, (Profit: 2.10 USD), Balance: 1054.95 USD, Comment: Test order;

  • Reversing position: 2013.08.13 01:53:36 EURUSD Buy 0.10 -> Sell 0.10, Op:1.32918, SL: 0.00000, TP: 0.00000.

  • Reaching critical equity or free margin level: 2013.08.13 13.35.08 Equity: 1047.95 USD, Free Margin: 782.00 USD.


Free Version and Version for MetaTrader 4

There is a free version of the program - NotifyMe Free for MT5. Unlike the full version, it allows only sending notifications of position opening or closing. Also, full and free versions of the application with similar features are available for MetaTrader 4 trading terminal.


Warning

The developer of NotifyMe for MT5 is not responsible for possible modification or termination of the program's operation due to changes in MQL5 language implemented by the trading terminal and language developer - MetaQuotes company. The developer of NotifyMe for MT5 is not responsible for any loss, damage or missed profits caused by the use of the program, its work or malfunction.


Contact Information

If you have any questions about the application, comments on its operation or suggestions for future improvements, please send them by email or leave your personal messages via this web site. Let me know what products (Expert Advisors, indicators, scripts) you would like to see.