FX Blue Auto-Restart for MT4 - User guide

Author: fxblue
For a PDF version of this user guide, please download the app



This document describes the Auto-Restart EA for MT4 which monitors the connection from MT4 to the broker. The monitor displays an alert within MT4 if the connection drops, and optionally sends an email, SMS, or MT4 push notification. It can also be configured to restart the MT4 application (because connection failures often require this intervention).

N.B. If the broker connection drops because the computer loses its internet connection entirely, then emails/SMS/push notifications cannot be sent. Therefore, these alerts are only useful in circumstances where it is only the connection to the broker which is lost.

To monitor a computer's internet connection, consider a tool such as FX Blue's Account Monitor.


Unless otherwise specified in writing by FX Blue, this software is licensed for personal use only. You are not allowed to distribute it to other people, regardless of whether or not money is changing hands. You only have a licence to use the software if you, personally, downloaded it from our website.

The software is provided entirely at the user's risk, and you should check it thoroughly before deploying it on computers trading real money. FX Blue accepts no responsibility whatsoever for any loss of any kind caused by installation or use of the software.

2.1Constituent parts

The broker-watch software consists of three parts:

  • An EA (.ex4 file) which you run on a chart within MT4
  • An executable and DLL which handle the optional restarts of MT4
  • A DLL for sending SMS. This is supplied separately.

2.2Installing the EA

The installer from our website lets you choose multiple copies of MT4 and then copies the sender and receiver EAs into MT4.

You need to restart MT4 in order for its Navigator list to update - or, in newer versions of MT4, you can use the "Refresh" option in the Navigator.

2.3Configuring the restart executable

The executable which is responsible for restarting MT4 can send email confirmations when it does a restart. This is in addition to the emails from MT4 itself when broker connections are lost/restored.

If you want these extra email notifications about restarts, you need to configure the executable with the email details to use. You simply run RestartMT4.exe and fill in your email server and account details.

3.1Running the monitor

You start the EA by opening a new chart (for any symbol), and dragging the EA from the MT4 Navigator window onto the chart, or by double-clicking on the EA (which adds it to the active chart).

N.B. You must turn on "Allow DLL imports" in order to use the broker-watch EA, and it will warn you if this is not switched on.

Once started, the EA then runs forever until you tell it to stop. If the EA is running when MT4 shuts down, it is automatically reloaded and restarted when MT4 restarts.

When the EA is started, it does not begin monitoring the connection until the first tick is received from the broker. Therefore, if the EA starts running while the connection is already down, you will not receive a warning message.


N.B. The EA's parameters cannot be changed in the usual way by right-clicking and choosing Expert Advisors/Properties (because the EA runs forever on a continuous loop rather than responding to each market tick). To alter the EA's properties, you have to re-add it to the chart.

3.2.1Notification parameters

The monitor has five notification parameters:

  • WarnAfterSeconds. Number of seconds to wait before issuing an alert that the connection has dropped. Zero (or a negative number) gives an immediate alert whenever a connection is lost.
  • SendEmail. If set to true, the EA sends an email alert when the connection drops (and when it is re-established). You need to configure your email details in MT4's Tools / Options / Email.
  • SendSMS. If set to true, the EA sends an SMS alert when the connection drops (and when it is re-established). SMS requires the separate FX Blue SMS library.
  • SendPushNotification. If set to true, the EA sends a push notification when the connection drops (and when it is re-established). You need to configure your details in MT4's Tools / Options / Notifications.
  • RestartMT4OnProblems. If true, the EA attempts to restart MT4 if the broker connection drops. Requires installation of the subsidiary .dll and .exe files.

3.2.2Broker-hour parameters

Many brokers do maintenance on their servers while the markets are closed over the weekend. To prevent false alarms, you can use the broker-hours parameters to define a period of time when the EA should not monitor the status of the connection.

All the following are defined in terms of your local time, according to your computer's clock, not the broker's time:

  • BrokerOpensOnDayOfWeek. The day of the week on which the broker opens according to your local clock, where 0 = Sunday and 6 = Saturday. Normal values for this are 0 (Sunday) or 1 (Monday).
  • BrokerOpensAtHour. The hour of the day on which the broker opens (e.g. 23 for 11pm).
  • BrokerOpensAtMinute. The minute of the hour on which the broker opens (usually zero).
  • BrokerClosesOnDayOfWeek. The day of the week on which the broker closes according to your local clock, where 0 = Sunday and 6 = Saturday. The normal value for this is 5 (Friday).
  • BrokerClosesAtHour. The hour of the day on which the broker closes (e.g. 22 for 10pm).
  • BrokerClosesAtMinute. The minute of the hour on which the broker closes (usually zero).

While your local time falls outside the opening hours defined by the above settings, the EA will display the status "[Broker closed - weekend]".

3.2.3Alert-text parameters

You can control the alert text which is sent by email/SMS using the LostConn_EmailSubject etc parameters. There are separate groups of settings for use when connections are lost and restored, and separate settings for email subject, email body text, and SMS text.

You can use the following variables in the text parameters:




Account number


Your computer's local time


Your broker's time


The time the connection was lost, according to your computer's clock


The broker name


The location of the MT4 instance, e.g. C:\Program Files\MT4

3.2.4Display parameters

While it is running the EA displays a status indicator in the top right of its chart. You can control the font and color used for this display using the StatusFont, StatusFontSize, and StatusFontColor parameters.

3.2.5Advanced parameters

There are two "advanced" parameters, only applicable if RestartMT4OnProblems is switched on.

WaitSecondsBeforeRestart defines the number of seconds between a problem being detected (i.e. when WarnAfterSeconds expires) and MT4 being automatically restarted. This defaults to a value of 60 to provide time for MT4 to send the lost-connection email before it is restarted.

RestartInPortableMode tells the software to restart MT4 in "portable" mode (equivalent to running it with the /portable command-line parameter).

3.2.6SMS parameters

The FX Blue SMS library is supplied separately. The meaning of the parameters for sending SMS is explained in that additional documentation.

3.3Status notification

While the EA is running it displays a simple one-line notification of the current connection status. You can control the font and color of this notification using the display parameters.


When the broker connection drops, and is not restored within the time period defined by WarnAfterSeconds, the EA displays an alert on screen and also optionally sends an alert by email/SMS/push notification. A further alert is then displayed/emailed when the connection is re-established.

The EA does not play sounds etc. when the connection drops, because MT4 does this itself.

If you use the facility for restarting MT4 automatically, the restart process can be configured to send its own separate confirmation. This has to use its own email settings rather than the ones you configure in MT4 itself. To set the email parameters for RestartMT4, simply run the RestartMT4.exe program.

N.B. It is strongly recommended that you do configure email details for RestartMT4 to use. It is theoretically possible for RestartMT4 to close MT4 without then being able to restart it again. You will only be informed of this critical problem if you provide email details for RestartMT4 to use.


The automatic restart of MT4 is often enough to resolve a broker connection problem. However, if MT4 still cannot connect after restarting then EAs will not get loaded. In other words, the broker-watch will not be able to take any further action after the restart because it is not running. Once the connection is finally restored - whether manually, or by itself - the EA will then get loaded, detect that the connection is okay again, and send out its all-clear email/SMS.

3.6Stopping the monitor

You can stop the EA in two ways: by closing the chart on which it is running, or by right-clicking over the chart and choosing Expert Advisors/Remove.

3.7Simulating connection problems

You can simulate a connection problem in order to test the software by doing the following:

  • Click on Tools/Options in MT4
  • On the Server tab, tick the "Enable proxy server" box
  • Click on the Proxy button, and fill in as the server
  • Click on the connection status icon in the bottom right of the MT4 window, and choose a different broker server from the pop-up menu.

You can then restore the connection again by doing the following:

  • Click on Tools/Options
  • On the Server tab, un-check the "Enable proxy server" box
HomeTerms & ConditionsPrivacyCookiesFAQ