Automating EA Restarts and Reboots on Your Forex VPS with Windows Task Scheduler

person
FXVPS
Share
Automating EA Restarts and Reboots on Your Forex VPS with Windows Task Scheduler

Getting an EA to start automatically when your VPS boots solves one problem. It does not solve the problem that shows up three weeks later, when MT4’s memory footprint has crept up from a slow leak, or a terminal has silently disconnected and never reconnected, or you simply want your VPS to reboot every Saturday during the weekend close instead of accumulating uptime indefinitely without a clean restart.

Windows Task Scheduler solves that second category of problem. It is built into every Windows Server installation, including every FXVPS instance, and it lets you trigger actions on a schedule or in response to a condition, not just at boot. Here is how to set it up for a trading terminal that needs to survive months of unattended operation.

💡 Tip: If you have not yet configured basic auto-login and auto-start for your terminal, do that first. See our MetaTrader 4 automatic startup guide. Task Scheduler builds on top of that foundation; it does not replace it.

Why Scheduled Restarts Matter for Trading Terminals

MT4 and MT5 are long-running desktop applications, not services designed for months of continuous uptime. Left running indefinitely, they can accumulate memory usage, especially with multiple chart windows, custom indicators computing on every tick, or EAs that allocate objects without fully releasing them. A terminal that has been open for six weeks straight is more likely to behave unpredictably than one that gets a clean restart on a predictable schedule.

📊 Key Stat: Memory leaks in MT4 terminals running heavy indicator stacks can add tens of megabytes of RAM usage per week in some configurations. On a Core plan with 2GB total RAM, that is a meaningful fraction of your headroom by week four or five, even before accounting for Windows itself and any other running processes.

The safest window for a scheduled restart is during a period when the market is closed or your EA is not expected to be managing open positions — for most forex traders, that means the weekend close.

Setting Up a Scheduled Weekly Reboot

  1. Open Task Scheduler. Search “Task Scheduler” in the Windows Start menu on your VPS.

  2. Create a new task (not a Basic Task, which has fewer trigger options) via Action > Create Task.

  3. Name it clearly, e.g. “Weekly VPS Reboot,” and under General, select “Run whether user is logged on or not” so it fires even if your RDP session is closed.

  4. Set the trigger. Under Triggers, add a new trigger set to “Weekly,” on Saturday, at a time comfortably inside your weekend market closure (for most forex pairs, Saturday afternoon in your broker’s server timezone is safe).

  5. Set the action. Under Actions, choose “Start a program,” and point it at shutdown.exe with arguments /r /t 60 — this restarts the machine 60 seconds after the task fires, giving any in-progress process a moment to close cleanly.

  6. Confirm auto-start is configured so MT4/MT5 and your EAs relaunch automatically once the machine comes back up, per the startup guide linked above.

⚠️ Warning: Never schedule an automatic reboot for a time when the market is open and your EA might have live positions. A restart mid-session means several minutes where no terminal is watching your trades, even though the positions themselves remain safely on the broker’s server. Weekend closures are the only universally safe window for forex; futures and crypto traders need to check their own market hours before choosing a time.

Setting Up a Watchdog Task for Crashed Terminals

A scheduled reboot handles gradual degradation. A watchdog task handles the sudden case: MT4 crashes, or the process is killed by an unexpected Windows update, and nothing relaunches it. Task Scheduler can check on a short interval and restart the terminal if it is not running.

  1. Create a new task as above, named something like “MT4 Watchdog.”

  2. Set the trigger to “On a schedule,” repeating every 5 or 15 minutes indefinitely.

  3. Set the action to “Start a program,” pointing to a small batch script (see below) rather than directly to terminal.exe, so you can add the “is it already running” check.

  4. Create the batch script. Save this as mt4watchdog.bat in a folder like C:\Scripts\:

@echo off
tasklist /FI "IMAGENAME eq terminal.exe" 2>NUL | find /I /N "terminal.exe">NUL
if "%ERRORLEVEL%"=="1" start "" "C:\Program Files\YourBroker MT4\terminal.exe" /portable

This checks whether terminal.exe is already in the running process list. If it is not found, it launches it. If it is already running, the script does nothing, so you never end up with duplicate terminal instances fighting over the same login.

  1. Point the watchdog task’s action at this script instead of directly at MT4.

Best Practice: Test your watchdog by manually closing MT4 and waiting for the next scheduled check. Confirm it relaunches and reconnects on its own before trusting it unattended. A watchdog you have not tested is a false sense of security.

Combining Both: A Realistic Schedule

For most EA traders, the practical setup is:

  • Watchdog task checking every 5-15 minutes, all week, to catch unexpected crashes fast.
  • Weekly reboot task on Saturday afternoon (broker server time), to clear accumulated memory and apply any pending Windows updates cleanly.
  • Auto-login and auto-start configured so both of the above result in a fully reconnected, trading-ready terminal without any manual intervention.

📊 Key Stat: A watchdog checking every 5 minutes catches a crashed terminal within an average of 2.5 minutes — far faster than most traders would notice on their own, especially overnight or during a workday when they are not watching the screen.

What This Doesn’t Replace

Task Scheduler automation reduces how often you need to manually intervene, but it is not a substitute for actually checking in on your VPS periodically. A watchdog that keeps relaunching a terminal that immediately disconnects due to a broker-side server issue, or an EA that is relaunching into a bad state after a crash, needs a human to notice the pattern. Pair this automation with the monitoring habits covered in our VPS performance metrics guide.

Frequently Asked Questions

Will a scheduled reboot close my open trades?

No. Open positions live on your broker’s server, not on your VPS. A reboot only interrupts your terminal’s connection to monitor and manage them, and with auto-start configured, that reconnection typically completes within a minute of the machine coming back online.

How often should I schedule a full reboot?

Weekly is a reasonable default for most EA setups. Lighter setups (one terminal, few indicators) can often go two weeks between reboots without issue. Heavier setups (multiple terminals, tick-data-hungry indicators) benefit from weekly or even more frequent restarts.

Can Task Scheduler restart Windows itself if it becomes unresponsive?

No. Task Scheduler runs within Windows, so it cannot recover from a fully frozen OS. For that level of failure, FXVPS’s infrastructure-level monitoring and support are the backstop — that is part of what you are paying for with managed hosting versus a bare unmanaged VPS.

Does the watchdog script work for MT5 the same way?

Yes, with one change: MT5’s process name is typically terminal64.exe rather than terminal.exe. Check Task Manager’s Details tab while MT5 is running to confirm the exact process name for your installation before writing the script.