Run MetaTrader (MT4/MT5) on a VPS to trade Forex around the clock

The currency market never sleeps from Sunday night to Friday evening. A VPS keeps MetaTrader and your robots online while your laptop is closed. This guide shows how to set it up cleanly.

MetaTrader terminal with candlesticks running on a server

A trading robot (Expert Advisor) or a simple trailing strategy is only worth something if it is connected the moment price moves. On a laptop, a Windows update, a dropped Wi-Fi connection, or a closed lid is enough to miss the London open. A VPS fixes that: it is a machine that stays on all the time, on a wired link, next to your broker's servers rather than at the end of your home router.

This guide walks through a clean install of MetaTrader 5 on an FFxF VPS, over RDP on Windows or with Wine on Linux. The steps are identical for MT4.

1. Why a VPS for Forex

Traders who move off their own machine tend to bring up the same arguments:

  • Uptime. Forex runs 24 hours a day, 5 days a week. An EA that manages its own positions has to stay connected across the whole window, even when nobody is sitting in front of the screen.
  • Latency. The time between your signal and execution at the broker matters, especially for scalping. A well-placed server on a stable link reduces slippage.
  • Stability. No sleep, no surprise reboots, no power cuts: the MetaTrader session stays open for weeks at a time.

One caveat before going further: a badly tested EA loses money on a VPS too, just without interruption. The machine takes care of execution. The rest is backtesting and discipline.

2. Windows or Linux?

MetaTrader is Windows software. Two ways to run it, both available at FFxF:

  • Windows VPS: MetaTrader installs natively and you connect over Remote Desktop (RDP). The simplest route if you want the exact interface you have on your desktop.
  • Linux VPS (Ubuntu) + Wine: lighter and cheaper, it runs MT5 inside a compatibility layer. Ideal for one or two automated terminals you almost never look at.

For a beginner, or to drive several accounts by hand, go with Windows. To leave EAs running in the background at the lowest cost, Ubuntu + Wine does the job well. The rest of this guide covers both.

3. The resources you need

MetaTrader itself is frugal. What consumes resources is the number of terminals, charts, and indicators open at once. A reasonable starting point:

  • 1 vCPU / 2 GB RAM for a single MT5 terminal with a few lightweight EAs.
  • 2 vCPU / 4 GB RAM as soon as you line up several accounts, heavy custom indicators, or a comfortable Windows VPS.
  • SSD/NVMe disk: 40 GB is plenty, since tick history stays modest.

Our VPS run on dedicated cores that are never oversold: the vCPU you pay for is genuinely available the instant an EA needs to compute, which matters more than the raw core count.

4. Install MetaTrader 5

On a Windows VPS, connect over RDP, download the installer from your broker's site (it comes preconfigured for their server) or from MetaQuotes, then follow the wizard. Enter your account number and the broker's server under File → Open an account.

On an Ubuntu VPS, install Wine and run the MT5 installer, which handles the compatibility layer itself:

bash
sudo dpkg --add-architecture i386
sudo apt update && sudo apt install -y wine64 wine32 winbind xvfb
wget https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe
wine mt5setup.exe

The graphical installer opens over the remote display; with no desktop, xvfb-run wine mt5setup.exe runs it on a virtual screen. Once installed, MT5 starts with wine ~/.wine/drive_c/Program\ Files/MetaTrader\ 5/terminal64.exe.

5. Keep it online 24/5

The whole point of a VPS is that MetaTrader restarts on its own after a reboot and runs without an open session.

On Windows, enable automatic sign-in for the account, drop an MT5 shortcut into the Startup folder, and in MT5 tick Tools → Options → Expert Advisors → Allow algorithmic trading. The terminal reloads its charts and EAs when the session opens.

On Linux, wrap the terminal in a systemd user service so it restarts by itself:

systemd: ~/.config/systemd/user/mt5.service
[Unit]
Description=MetaTrader 5
After=network-online.target

[Service]
ExecStart=/usr/bin/xvfb-run -a wine "/home/florian/.wine/drive_c/Program Files/MetaTrader 5/terminal64.exe" /portable
Restart=always
RestartSec=15

[Install]
WantedBy=default.target
bash
systemctl --user enable --now mt5.service
sudo loginctl enable-linger florian

Do not skip the enable-linger: without it, user services stop the moment you close your SSH session. With it, MT5 keeps running after you disconnect and comes back after a reboot.

6. Lock down access

A trading VPS holds the credentials of an account tied to real money: it deserves better than an Admin/Admin password.

  • Windows/RDP: do not expose port 3389 to the open internet. Restrict it to your IP in the firewall, or reach it through a WireGuard VPN tunnel to the VPS.
  • Linux/SSH: key-only login, root disabled, firewall default-deny. The full walkthrough is in our hardening guide.
  • Broker account: turn on two-factor authentication at the broker where available, and never save the master password in the terminal if the read-only "investor" password is enough for your use.

To go further, our article Secure an Ubuntu VPS covers SSH, UFW, and fail2ban, and Set up a WireGuard VPN shows how to open RDP only through an encrypted tunnel.

7. Backups and monitoring

Your settings have value: chart profiles, EA parameters, indicator sets. Take a backup once the install is stable, then after every strategy change. On our VPS, 7 manual backups are included and fire with one click from the console.

For monitoring, one simple test: cut your local connection and check, an hour later, that MetaTrader still shows fresh ticks and that the Algo Trading button is green. That is proof the "VPS → broker → EA" chain holds without you.

Checklist

  • VPS chosen: Windows (RDP) for simplicity, or Ubuntu + Wine for cost.
  • Resources sized to the number of terminals and EAs.
  • MetaTrader installed, broker account and server entered.
  • Auto-restart on boot (Windows Startup or systemd service + linger).
  • Algorithmic trading allowed in the options.
  • Access locked down: restricted RDP or key-based SSH, firewall on.
  • A backup taken once the configuration is finished.

What is left to pick is the VPS itself. Its location relative to your broker and its resources decide how smooth execution feels; that is what the next article covers.