The script worked for eleven days. Then the MT5 VPS installed a Windows update at 03:40 on a Tuesday, rebooted, came back with the terminal closed, and the strategy sat out the London open while a green "online" light on the hosting dashboard insisted everything was fine.
If you've automated MetaTrader 5 for more than a month, you have a version of that story. Below: the thing that causes it, what the fix actually costs, and when you should keep the VPS anyway.
What a Windows MT5 VPS setup actually involves
Start with the bit nobody writes down. To run MT5 automation from your own code, you need:
- A Windows machine. MetaTrader 5 is a Windows desktop application. The
official
MetaTrader5Python package talks to it over local IPC and is itself Windows-only. So the box is Windows, full stop. - A terminal that stays logged in. Not installed. Logged in, with the account selected, the connection green, and (if an EA is involved) AutoTrading enabled. Every one of those is a separate thing that can be false after a reboot.
- RDP access, because sooner or later you'll need to click something.
- One terminal per account. The Python package binds to one terminal, and
a terminal logs into one account. Three accounts is three terminal
processes, three
terminal64.exeinstances eating RAM, three things to keep logged in. - A watchdog. Something has to notice the terminal isn't running and relaunch it: Task Scheduler, a batch file in a loop, NSSM, a second Python process that watches the first. You will write this after the second outage, not before.
- A way to get data out. Either the Python package on the same box, an EA writing files, an EA opening a socket (ZeroMQ is the usual choice), or some vendor's bridge DLL. Each is its own protocol you now own.
- Windows Update policy. You can defer it. You can't disable it forever, and deferring it is how you end up on a build the broker's terminal no longer likes.
None of these is hard. All of them together is a part-time sysadmin job that you didn't sign up for when you wanted to pull deal history into a dashboard.
The real monthly bill
A forex-grade Windows VPS (low latency to the broker, enough RAM for a few terminals) runs somewhere in the range of $15 to $40 a month for one small box. Cheaper exists, and it's usually the box that swaps when the second terminal opens. More expensive exists too, for the people who host six accounts and want an NVMe disk.
That's the easy number. The honest one is hours.
Setting it up the first time is an afternoon: install Windows updates, install the terminal, log in, install Python, install the package, test, configure the watchdog, disable sleep, set the RDP password to something you'll remember. Call it four hours if nothing goes wrong.
Then it's maintenance. A reboot you didn't schedule. A terminal update that changes the data folder layout. The broker pushing a new server list. The package version drifting from the terminal build. Say two hours a month on a good month, and a wasted weekend twice a year. At any rate you'd bill a client, the hours cost more than the box.
And that's for one account. The cost scales with terminals, not with the number of API calls you make.
"Uptime" means the terminal, not the box
This is the part that bites experienced people. The VPS provider reports 99.9%
uptime and they aren't lying: the Windows box was up. But "up" is not the
question. The question is whether terminal64.exe was running, logged in,
connected to the broker, and responding to your process.
A terminal can be running and silently disconnected. It happens after a broker
server switch, after a network blip that outlasts the reconnect window, after
the account password is changed elsewhere, after a "Common" error dialog
appears and waits for a click nobody is there to give. The Python package
happily returns None from positions_get() in that state, and
last_error() tells you (-10004, 'No IPC connection') or nothing helpful at
all.
So you add a heartbeat: call terminal_info() every 30 seconds and check
.connected. Then you add an alert when it's false. Then you add the relaunch.
Then you discover the relaunch doesn't help when the problem is a modal dialog.
This is the watchdog from item 5 growing into a small product of its own.
Run MetaTrader 5 without a VPS: a hosted terminal per account
The alternative is to move the terminal somewhere that treats "logged in and connected" as its job, and to talk to it over HTTP instead of local IPC.
That's what we built MetaKit to be. Each connected
account gets its own isolated terminal in a Linux container (MT5 under Wine,
one account per container; we wrote up the
Docker and Wine details
separately). You never see the terminal. You see a REST API at
https://api.metakit.cloud/v1 and a status field that tells you whether the
account is connected.
Connecting an account is one request:
curl -X POST https://api.metakit.cloud/v1/accounts \
-H "Authorization: Bearer $METAKIT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Live 40317",
"number": 40317,
"password": "investor-password",
"broker_id": 210,
"server": "ICMarketsSC-Live",
"type": "readonly"
}'First connect takes from about 30 seconds to a few minutes while the account
moves through provisioning and starting. After that, everything hangs off
/v1/accounts/{id}: positions, pending orders, deals, candles, ticks, and a
/performance endpoint that does the deal-grouping analytics for you. The
Python walkthrough shows the
status-polling pattern, and the full reference is in
llms.txt.
Reconnects, restarts, and the "is the terminal actually connected" question
are handled on our side. When one does drop, the account's status moves to
error, an account.error webhook fires, and it comes back as connected
with an account.connected event. Your code reads one field instead of
polling a process list over RDP.
The price is per account, not per call: $5 a month for a read-only slot (investor password) and $10 for a full slot (master password, required if the account is a copier follower). There's no API tier and no metering. One account with a dashboard is $5. Ten accounts is $50 or $100, and still zero terminals on your side.
Set that against the VPS: for a single account the box alone costs more than the read-only slot, before your hours. For several accounts it isn't close.
When the VPS is still the right answer
Fairness matters here, because the VPS is not a mistake. It's the right tool for three cases, and if you're in one of them you should stay.
You run your own EA with custom logic on the chart. An Expert Advisor is MQL5 code executing inside the terminal, with access to every tick, every chart event, and the strategy tester. MetaKit doesn't run your EA. If your edge lives in MQL5, the terminal has to be yours, and the VPS is where it lives. The MT5 API guide covers why MQL5 is still the only first-class citizen for that job.
You need sub-100ms execution from your own code. A REST hop is a network round trip. Our copier fills a follower consistently under a second after the master fill, which is fine for copy trading and irrelevant for analytics, but it is not the same as an EA reacting to a tick in-process on a box in the broker's data centre. If you're scalping on latency, you know this already.
You don't want a third party holding an investor password. Legitimate. Connecting an account means giving us the login and the password (write-only, never returned by any endpoint, but held). If your compliance rules, your client agreement, or your own comfort say no, the answer is no, and a VPS you control is the alternative. The investor vs master password post is worth reading either way, because a read-only investor password limits the blast radius a lot.
A fourth, smaller case: you only ever run one demo account on your own PC for research. Don't pay anyone. Use the Python package on your desktop and be happy.
The trade you're actually making
Strip everything else away and the choice is this: a Windows box you supervise, or an account id you query. The VPS gives you the terminal, and with it the ability to run code inside it and full control over who holds the credentials. The hosted terminal takes the terminal away from you, and with it the 03:40 reboot, the watchdog, the modal dialog, and the RDP session.
If you've never written the watchdog, try the VPS first. You'll know within a month which side of that trade you're on.