Hosting and setup

Do You Need a VPS to Automate MetaTrader 5?

Local terminal, rented VPS or hosted API: where MT5 automation actually runs, what each setup asks you to maintain, and when a VPS is the right answer.

The fxapis team3 min read

In short

  • Automation needs something that is always on and logged in to your broker. On your own setup, that is a MetaTrader 5 terminal — so the real question is where that terminal runs.
  • A VPS keeps a terminal running when your computer is off. You still install, update, restart and watch it, one terminal per account.
  • A hosted MT5 API runs the terminals for you: your code sends HTTPS requests, and there is no terminal, VPS or Expert Advisor on your side.
  • A VPS is still the right tool for an Expert Advisor you wrote in MQL5. For a product that trades over an API, or for many accounts, hosting removes the server work.
On this page
  1. Why automation needs an always-on machine
  2. The three setups
  3. Who maintains what
  4. When a VPS is the right answer
  5. What a hosted API does not replace
  6. Next steps

Short answer: you need something that is always on and logged in to your broker — but it does not have to be your VPS. MetaTrader 5 automation runs wherever an MT5 terminal is running. A VPS is one place to put that terminal. A hosted API is another, where somebody else runs it.

Which one fits depends less on speed than on who you want maintaining the terminal.

Why automation needs an always-on machine

MetaTrader 5 is a desktop application. Everything that trades for you — an Expert Advisor, a script, the official Python package — runs inside a terminal process that is logged in to one trading account at your broker. Close the terminal, let the laptop sleep, or lose the connection, and that automation stops.

Some things keep working without your terminal, because the broker holds them: open positions, their stop losses and take profits, and pending orders. Anything that decides to trade does not.

So the question "do I need a VPS?" is really "where should the terminal run?"

The three setups

1. A terminal on your own computer

The simplest start. Install MetaTrader 5, log in, attach your Expert Advisor or run your script.

It works for as long as the computer is on, awake and online. Updates, reboots, power cuts and a closed lid all pause your automation, usually without telling you.

2. A terminal on a rented VPS

A virtual private server is a computer in a data centre that does not sleep. You install the terminal there, often a Windows build, and connect to it remotely. Many brokers and MetaQuotes itself offer hosting for exactly this.

It solves "my computer is off". It does not remove the work: you still install and update the terminal, keep it logged in after a broker disconnect, watch disk and memory, and notice when it has quietly stopped. And one terminal is logged in to one account, so ten accounts means ten terminals to look after.

3. A hosted MT5 API

A hosted API runs the terminals for you and exposes them over HTTPS. You connect an account with its login, password and server once, then your code — on any operating system, in any language — places orders with requests like this:

cURL
curl -X POST https://api.fxapis.com/v1/accounts/$ACCOUNT_ID/orders/market \
  -H "Authorization: Bearer $FXAPIS_KEY" \
  -H "Idempotency-Key: 7f3e0c9a-order-1" \
  -H "Content-Type: application/json" \
  -d '{ "symbol": "EURUSD", "side": "buy", "volume": "0.10" }'

There is no terminal, VPS or Expert Advisor on your side. With fxapis, an account can stay connected all the time or come online when it is needed — about 10 seconds in our measurements — and go offline by itself when idle.

Who maintains what

AspectOwn computerRented VPSHosted API
Runs while you are offlineNoYesYes
Terminal installs and updatesYouYouThe provider
Re-login after a disconnectYouYouThe provider
One terminal per accountYes, yoursYes, yoursHandled for you
Where your code runsNext to the terminalNext to the terminalAnywhere with HTTPS
Runs MQL5 Expert AdvisorsYesYesNo — your code calls the API
Monthly costElectricityThe VPS planThe API plan

When a VPS is the right answer

Choose a VPS when your strategy is an Expert Advisor written in MQL5 and you want to keep it that way, when you trade one or two accounts of your own, or when your strategy needs a server in the same data centre as the broker.

Choose a hosted API when you are building a product — a signal service, a copier, an app — where other people's accounts are traded from your own backend, or when you would rather not run Windows servers at all. Code that already speaks HTTP does not need to move next to a terminal.

What a hosted API does not replace

Be clear about the trade-off before you switch. fxapis is for trading accounts and reading their history; it does not stream prices or serve bars and ticks, so a strategy that computes signals from MT5 market data needs a data source for that part. It supports MetaTrader 5 only, not MT4.

Next steps

  • See how the API works on the MT5 API page, and what it costs on pricing.
  • Running the official package on Linux or macOS today? The Linux and macOS guide maps each call to its HTTP equivalent.
  • Ready to try it: the quickstart goes from an API key to a filled demo order in about five minutes.
FAQ

Questions people also ask

Can I automate MT5 without a VPS?

Yes, in two ways. Keep a MetaTrader 5 terminal running on a computer that never sleeps, or use a hosted MT5 API such as fxapis, which runs the terminal in its own cloud while your code sends HTTPS requests from anywhere.

Does an Expert Advisor need a VPS?

An Expert Advisor runs inside a MetaTrader 5 terminal, so it only works while that terminal is open and connected. To run it around the clock you need a machine that stays on — your own, a rented VPS, or MetaQuotes' virtual hosting.

Do stop losses work if my VPS goes down?

Yes. Stop loss, take profit and pending orders are held by the broker's trade server, not by your terminal. What stops working is anything your terminal does itself: Expert Advisors, scripts and trailing stops.

Is a hosted API slower than a VPS near the broker?

Not necessarily. Latency is the distance to the broker's trade server. fxapis runs in the EU; we measured an order's round trip to a London broker's trade server at 96–110 ms. A VPS in the same data centre as the broker can be faster, which matters for some strategies and not for most products.

> Connect. Execute. Scale.

Trade MT5 from your own code.

Connect accounts by login, password and server, and place orders over HTTPS. We run MetaTrader 5; you install nothing.