Auto-Restart of MetaTrader4 When the Connection Is Lost

AutoRestart MT4
Everyone is familiar with the trilling sound that the Metatrader 4 terminal makes when the connection is lost. After a couple of seconds, sometimes minutes, the connection is restored and the program continues normal operation. But sometimes after the connection is lost the terminal "freezes up" and only a restart can help. If at that moment you are near the computer, then everything is ok. But if an expert advisor is running on your account, and the terminal is installed on a VPS server, then such a situation can lead to large losses... What to do? How to protect yourself and your account from such force majeure? There is an answer.

And it is called MT4 AutoRestart. This script is intended for automatically restarting Metatrader4 when connection problems are detected, and it is also capable of sending notifications by e-mail. A large number of settings will help avoid unnecessary restarts in situations where the connection restores itself after a few seconds.

Installation

MT4 AutoRestart is made in the form of an expert advisor, so it is installed in the same way as any other trading expert (see How to install a forex expert advisor). We attach the expert advisor to the chart of any currency pair, on any timeframe.

Description of MT4 AutoRestart settings

Note: please note that the settings of the expert advisor can only be changed at the moment of installation on the chart, so to change something you first need to remove the expert from the chart and attach it again.

WarnAfterSeconds - after how many seconds after the connection is lost to send a notification and/or restart the terminal

SendEmail - on/off e-mail notifications

RestartMT4OnProblems - on/off automatic MT4 restart when connection problems are detected

Many brokers carry out maintenance work on weekends, during which the terminal loses connection with the server, so in order not to perform an auto-restart unnecessarily during weekend periods, we can configure in the expert advisor the working hours of our broker (all time settings are based on the clock of the computer on which the terminal is installed, do not pay attention to the broker's time):

BrokerOpensOnDayOfWeek - set the number 0 (Sunday) or 1 (Monday), depending on which day by the computer clock our broker opens.

BrokerOpensAtHour - broker trading opening hour

BrokerOpensAtMinute - broker trading opening minutes (addition to the hour)

BrokerClosesOnDayOfWeek - set the number 5 (Friday) or 6 (Saturday), depending on which day by the computer clock our broker closes.

BrokerClosesAtHour - broker trading closing hour

BrokerClosesAtMinute - broker trading closing minutes (addition to the hour)

Settings for the text of e-mail notifications are also available.

Note: to enable e-mail notifications, you need to configure them in advance by running the file RestartMT4.exe (located in the experts\libraries folder). Gmail and Yahoo mail are supported.

Download MT4 AutoRestart

Download MT4 AutoRestart advisor

Important! Nuances of installation in new MetaTrader 4 builds

Everyone is familiar with the trilling sound the Metatrader 4 terminal makes when the connection is lost.