Auto-Restart MetaTrader4 in case of loss of connection
Everyone is familiar with the tinkling sound that the Metatrader 4 terminal makes when a connection is lost. After a couple of seconds, sometimes minutes, the connection is restored and the program continues to work normally. But sometimes the terminal after a loss of connection is “stupid” and only rebooting can help. If at this moment you are near the computer, then everything is ok. And if an adviser works on your account, and the terminal is installed on a VPS server, then this situation can lead to big losses ... What should I do? How to secure yourself and your account from such force majeure? There is an answer.
And he is called MT4 AutoRestart. This script is designed to automatically restart Metatrader4 when it detects communication problems, it is also able to send notifications by e-mail. Many settings will help to avoid unnecessary reboots in situations when the connection is restored by itself after a few seconds.
MT4 AutoRestart is made in the form of an adviser, therefore it is installed just like any other trading expert (see How to install a forex advisor). We attach the adviser to the chart of any currency pair, on any timeframe.
MT4 AutoRestart Settings Description
Note: please note that the advisor settings can only be changed at the time of installation on the chart, therefore, to change something, you must first remove the expert from the chart and attach it again.
WarnAfterSeconds - how many seconds after the loss of communication send a notification and / or restart the terminal
Sendemail - on / off mail notification
RestartMT4OnProblems - on / off automatic reboot MT4 when detecting communication problems
A lot of brokers perform preventive work on weekends, during which the terminal’s connection with the server is lost, so as not to do auto-reboot again during the weekend, we can configure our broker’s hours of operation in the adviser (all time settings are based on the clock of the computer on which the terminal is installed , - do not pay attention to the broker):
BrokerOpensOnDayOfWeek - put the number 0 (Sunday) or 1 (Monday), depending on what day our broker opens according to the clock of the computer.
BrokerOpensAtHour - hour of opening a broker trade
BrokerOpensAtMinute - minutes of opening a broker's trade (addition to an hour)
BrokerClosesOnDayOfWeek - put the number 5 (Friday) or 6 (Saturday), depending on what day our broker closes according to the clock of the computer.
BrokerClosesAtHour - hour of closing the broker's trade
BrokerClosesAtMinute - minutes of closing the broker's trade (addition to the hour)
Settings for the text of email notifications are also available.
Note: to enable notifications by mail, you need to configure them in advance by running the file RestartMT4.exe (located in the experts libraries folder). Gmail and Yahoo are supported.