tocOn this page 6 sections
To move MetaTrader to a VPS without losing anything, install the same broker's terminal on the VPS, run it once and close it, then copy your old data folder contents into the new one. For MT5 that means the MQL5 folder, which also holds templates and profiles. For MT4 it means MQL4, templates and profiles. Then log in, re-tick the Expert Advisor options, and turn off AutoTrading on your PC before you enable it on the VPS so the same account is never traded twice.
Find the data folder on your PC
A standard install keeps EAs and layouts under %APPDATA%\MetaQuotes\Terminal\<32-character ID>\, not in C:\Program Files. The ID is a hash of the install path, so two terminals from different brokers get two folders. Open File > Open Data Folder in the terminal, or list every folder with its install path in PowerShell, because each one contains an origin.txt:
Get-ChildItem "$env:APPDATA\MetaQuotes\Terminal\*\origin.txt" |
ForEach-Object { '{0} {1}' -f $_.Directory.Name, (Get-Content $_) }
What to copy depends on the platform:
- MT5: the whole
MQL5\folder. It containsExperts,Indicators,Scripts,Include,Libraries,Files,Presets(.set input files),Profiles\Templates(.tpl) andProfiles\Charts(layouts). - MT4:
MQL4\(same subfolders, with presets inMQL4\Presets), plustemplates\andprofiles\at the root of the data folder. - Both:
%APPDATA%\MetaQuotes\Terminal\Common\Filesif any EA writes with theFILE_COMMONflag.
A profile stores each chart's symbol, timeframe, attached EA and its input values, so restoring it brings back a running setup in one step. Skip logs\, tester\, history\ (MT4) and bases\ (MT5). They can run to several GB, and the terminal downloads quotes again from the broker.
Package the files on your PC
Close the terminal first: MetaTrader writes the current profile on exit. Confirm nothing is still running, then zip. For MT5:
Get-Process terminal, terminal64 -ErrorAction SilentlyContinue
$src = "$env:APPDATA\MetaQuotes\Terminal\<ID>"
Compress-Archive -Path "$src\MQL5" -DestinationPath "$env:USERPROFILE\Desktop\mt-migrate.zip"
Get-FileHash "$env:USERPROFILE\Desktop\mt-migrate.zip"
For MT4, use -Path "$src\MQL4","$src\templates","$src\profiles". Write down the SHA256 hash so you can compare it on the VPS. If you have .mq4/.mq5 source files, they travel in the same folder and can be recompiled in MetaEditor with F7. Compiled .ex4/.ex5 files without source copy across and run as they are.
Get the archive onto the VPS
Use RDP drive redirection. In mstsc, open Show Options > Local Resources > More, tick Drives and connect. In a saved .rdp file the same setting is drivestoredirect:s:*. Your PC's disk then appears on the VPS as \\tsclient\C:
New-Item C:\Temp -ItemType Directory -Force
Copy-Item "\\tsclient\C\Users\<you>\Desktop\mt-migrate.zip" C:\Temp\
Get-FileHash C:\Temp\mt-migrate.zip
Expand-Archive C:\Temp\mt-migrate.zip -DestinationPath C:\Temp\mt-migrate
If the two hashes differ, copy the file again. Pasting a file through the RDP clipboard works for small archives, but it fails without a clear error more often than drive redirection does.
Install the terminal and merge the files
- Download the installer from your broker's site so the trade server list matches, and install it on the VPS.
- Start the terminal, open File > Open Data Folder, note the new ID, and exit with File > Exit.
- Merge your files into the new data folder with robocopy:
$dst = "$env:APPDATA\MetaQuotes\Terminal\<new-ID>"
robocopy C:\Temp\mt-migrate $dst /E /XO /R:1 /W:1 /LOG:C:\Temp\mt-copy.log
/E includes all subfolders. /XO skips files that are older than the copies already on the VPS, so the fresh install keeps its newer built-in indicators. Robocopy exit codes below 8 mean success. Check mt-copy.log for anything listed as FAILED.
Portable mode is the cleaner option if you plan to run several terminals. Install to a separate folder such as C:\MT5-BrokerA\, copy MQL5 (or MQL4, templates and profiles) into that folder, and create a shortcut to terminal64.exe /portable (terminal.exe /portable for MT4). The data then sits next to the program, and you back up one folder per terminal.
Restore the profile and re-enable trading
- Log in with File > Login to Trade Account. Saved passwords do not reliably carry over between machines.
- Load your layout from File > Profiles.
- Open Tools > Options (Ctrl+O) > Expert Advisors. Tick Allow algorithmic trading (MT4: Allow automated trading), and Allow DLL imports and the Allow WebRequest for listed URL entries if your EAs need them. Profiles do not store these options.
- On each chart press F7 and compare the Inputs tab with your PC, especially the magic number.
Disable AutoTrading on the PC and close that terminal, then click Algo Trading on the VPS. Two terminals running the same EA on one account will open duplicate orders. EAs bought on the MQL5 Market do not move as files: reinstall them from the Market tab while signed in to your MQL5 account. Each reinstall on new hardware uses one activation.
For the rest of the server setup, follow our guides to keeping MT5 EAs trading 24/7 and configuring MT4 on a Windows VPS. Then set the terminal to restart after Windows Update reboots. Plans and locations are on our Windows VPS for forex trading page.
FAQ
Can I just copy the Program Files folder?
Only if the old terminal already ran with /portable. A standard install keeps EAs, templates and profiles under %APPDATA%\MetaQuotes\Terminal, so copying Program Files alone moves the software and leaves your setup behind.
Will my open trades survive the move?
Yes. Positions live on the broker's server. The EA picks them up again as long as exactly one terminal runs it and its magic number input is unchanged.
Why are my MT5 templates missing after copying?
MT5 keeps them in MQL5\Profiles\Templates, not in a root templates folder as MT4 does. Copy the whole MQL5 folder and they come with it.
Run this on your own Windows VPS
Get a Windows VPS from WindowsVPS in about 60 seconds, with full Administrator access over RDP, NVMe storage and the Windows license included.
Written by the WindowsVPS Team
We run Windows Server VPS hosting and write these guides from the same setups our customers use: RDP, PowerShell, trading terminals and always-on bots. Questions about a guide? Contact us.