On this page
Back to tutorials

Deploy and Maintain Your MT5 EA: Demo to Live + VPS Checklist

Take your EA live: compile, backtest, then deploy to Demo and Live. VPS setup, broker connection, logging, debugging, and ongoing maintenance — no guesswork.

📖 28 min read

📝 5,500 words

🏷️ MQL5 & Expert Advisors

Share this article:

Want to build a no-code strategy right now?

Create your free account in seconds and start building immediately.


Deploy and Maintain Your EA — From Code to Live Trading Safely

You've built your EA, added risk management and filters. Now you need to deploy it correctly and maintain it so it trades reliably. According to the MetaTrader 5 Strategy Tester documentation, you must test on historical data before live trading — the tester lets you run backtests in minutes instead of weeks. This guide walks you through compile → backtest → Demo → Live, plus VPS setup, logging, debugging, and ongoing maintenance — no guesswork.


Why Deploy & Maintain Properly

What goes wrong if you skip steps? Many traders deploy an EA straight to Live without proper backtesting or Demo validation. Result: bugs surface in real money, parameters are over-fitted to past data, or the EA stops when the PC goes to sleep. A structured process — compile → backtest → Demo → Live — reduces risk and catches issues early.

What we'll cover:

TopicPurpose
Compile and verifyFix errors before testing; ensure .ex5 is built
Backtest thoroughlyTest on historical data; choose tick mode, date range
Deploy to Demo firstValidate on real ticks before Live; no real money risk
VPS setupRun EA 24/5 near broker; no PC dependency
Logging and debuggingTrack EA behavior; diagnose OrderSend failures
Go Live checklistFinal checks before switching to real account
Ongoing maintenanceMonitor performance; update parameters; check logs

Step 1: Compile and Verify

What is this? Compilation turns your .mq5 source into an .ex5 executable. MetaTrader 5 runs .ex5 files — if you have compile errors, no .ex5 is created and the EA won't appear in the Navigator.

Why it matters: Typos, missing semicolons, wrong types, or undefined variables cause compile errors. Fix them in MetaEditor before testing.

How it works: Open your EA in MetaEditor, press F7 (or Compile). Check the Toolbox — Errors tab. Zero errors means success; the .ex5 file is created in the same folder as the .mq5. Warnings don't block compilation but may indicate logic issues — fix them when possible.

Checklist:

  • 0 errors in Toolbox
  • .ex5 file exists in MQL5\Experts (or subfolder)
  • Right-click Navigator — Refresh to see the EA in MetaTrader 5

Step 2: Backtest Thoroughly

What is this? Backtesting runs your EA on historical data — the Strategy Tester simulates ticks or bars and the EA places virtual trades. You get a report: profit, drawdown, number of trades, etc. Per MetaTrader 5 Strategy Tester, the tester uses accumulated quotes and performs virtual transactions according to your algorithm.

Why it matters: Backtesting shows how the EA would have performed in the past. It doesn't guarantee future results, but it helps find bugs (e.g. no trades, wrong lot, logic errors) and evaluate robustness.

Testing modes (from official docs):

  • Every tick — Most accurate, slowest. Best for scalping or tick-sensitive logic.
  • 1 minute OHLC — Good balance of speed and accuracy. Recommended for most EAs.
  • Open prices only — Fastest, least accurate. Rough estimation only.

Steps:

  1. Open View — Strategy Tester (Ctrl+R)
  2. Select your EA, symbol, timeframe, date range
  3. Set Deposit (e.g. 10000), Leverage (e.g. 1:100)
  4. Choose 1 minute OHLC or Every tick depending on your strategy
  5. Click Start
  6. Review Results, Graph, Journal tabs after completion

Forward testing: Use the built-in forward testing option to split data — optimize on the first part, validate on the second. This reduces over-fitting.


Step 3: Deploy to Demo First

What is this? Before Live, run your EA on a Demo account — real market data, real broker execution, but virtual money. This catches issues that backtesting might miss (e.g. requotes, slippage, broker-specific behavior).

Why it matters: Demo uses the same server as Live (often). If the EA works on Demo, it's more likely to work on Live. Run for at least a few days (or weeks) to observe behavior across different market conditions.

How it works:

  1. Open a Demo account (File — Open an Account — Demo)
  2. Open a chart (e.g. EURUSD H1)
  3. Drag your EA from Navigator onto the chart
  4. Configure inputs, click OK
  5. Enable AutoTrading (Ctrl+E) — toolbar button must be green
  6. Check Tools — Options — Expert Advisors: "Allow Algo Trading" must be checked
  7. In EA Properties — Common tab: check "Allow live trading" (required for Demo too)
  8. Monitor the Experts tab for messages and errors

Step 4: VPS Setup

What is this? A VPS (Virtual Private Server) is a remote computer that runs 24/7. You install MetaTrader 5 on it, attach your EA, and it runs even when your home PC is off. Many brokers offer a free VPS if you meet minimum deposit or volume.

Why it matters: EAs need continuous execution. Power cuts, internet outages, or PC sleep will stop the EA — you miss trades or can't close positions. A VPS near the broker also reduces latency.

How it works:

  1. Request VPS from your broker (or use a third-party VPS provider)
  2. Connect via Remote Desktop (RDP) to the VPS
  3. Install MetaTrader 5 and your EA
  4. Log in with your Live (or Demo) account
  5. Attach EA to chart, enable AutoTrading
  6. Disconnect — the EA keeps running on the VPS

Tip: Choose a VPS in the same region as your broker's server (e.g. London for UK brokers) for lowest latency. For a full guide, see VPS for Expert Advisors.


Step 5: Logging and Debugging

What is this? Logging means writing messages from your EA to the Experts tab and log files. Print() writes to the Experts log; Comment() displays text on the chart. Use them to track variable values, entry/exit reasons, and errors.

Why it matters: When the EA doesn't trade or behaves unexpectedly, logs help you find the cause. After OrderSend, check GetLastError() to see the trade server return code (e.g. 134 Not enough money, 130 Invalid stops).

How it works:

// Log key values
Print("Signal: Buy. Price=", SymbolInfoDouble(_Symbol, SYMBOL_ASK), " Lot=", lot);

// After OrderSend
if(!OrderSend(req, res))
   Print("OrderSend failed: ", GetLastError(), " ", res.comment);

// Display on chart (useful for debugging)
Comment("Positions: ", countMyPositions(), " | Last error: ", GetLastError());

Note: Print() does not work during Strategy Tester optimization. It works in single run and live/Demo.


Step 6: Go Live Checklist

What is this? Before switching to a Live account, run through a final checklist to avoid common mistakes.

Checklist:

  • EA backtested and Demo-tested for at least a few days
  • Risk settings (lot, SL, TP) appropriate for Live account size
  • AutoTrading enabled (Ctrl+E)
  • Allow Algo Trading checked in Options
  • EA Properties — Allow live trading checked
  • VPS running (if using) and EA attached
  • Symbol in Market Watch; sufficient margin
  • Experts tab monitored for errors

Step 7: Ongoing Maintenance

What is this? Once Live, you should monitor the EA regularly: check the Experts tab, review open positions, and review periodic performance. Update parameters if market regime changes; fix bugs if errors appear.

Why it matters: Markets change. Parameters that worked last month may underperform now. Logs can reveal broker issues (e.g. frequent requotes) or EA bugs.

Practices:

  • Check Experts tab daily (or use email/SMS alerts for critical errors)
  • Review weekly: profit, drawdown, number of trades
  • Re-optimize or adjust parameters periodically (e.g. quarterly) if performance degrades
  • Keep a backup of working .mq5 and .set files

Summary

You learned: compile and verify (F7, 0 errors), backtest (Strategy Tester, tick modes, forward testing), deploy to Demo first, VPS setup for 24/5 operation, logging and debugging (Print, Comment, GetLastError), Go Live checklist, and ongoing maintenance. Follow this flow — compile → backtest → Demo → Live — and your EA deployment will be safer and more reliable.

Bonus Tip: Want to skip the compile-and-deploy steps? Try AlfaTactix Strategy Builder free — design your EA visually, export production-ready MQL5, then deploy to MetaTrader 5. Backtest-ready code in minutes. Same deployment flow, faster start.


Troubleshooting

SymptomCauseFix
EA not in NavigatorCompile errors, or file not in MQL5\ExpertsFix errors in MetaEditor (F7), save in Experts folder, refresh Navigator.
No trades in backtestWrong symbol, date range, or EA logicEnsure symbol in Market Watch, history downloaded, check Journal for messages.
"Trade not allowed" (64)AutoTrading off, or Allow Algo Trading uncheckedEnable AutoTrading (Ctrl+E), Options — Expert Advisors — Allow Algo Trading.
"Not enough money" (134)Lot too large for depositReduce lot size or increase deposit in Strategy Tester / Live account.
EA stops when PC sleepsEA runs on local PCUse VPS — EA runs on remote server 24/7.
Print() shows nothingRunning optimizationPrint() doesn't work during optimization; use single run or Live.

See MQL5 Trade Return Codes for all error codes.

Build your no-code trading strategy now — free

Create your account and start building a complete no-code strategy right now. Add indicators, filters, and risk rules, then export MQL5 in minutes.

Frequently Asked Questions

Yes. Always backtest on historical data first, then run on Demo for at least a few days (or weeks) before Live. The Strategy Tester lets you run tests in minutes — use Every tick or 1 minute OHLC for accuracy.

If you run the EA 24/5, yes. Your PC must stay on, and power/internet outages will stop the EA. A VPS runs 24/7 near the broker — lower latency, no dependency on your home connection. Many brokers offer free VPS.

Use Print() to log key values to the Experts tab and log files (MQL5/Logs). Use Comment() to display info on the chart. Check GetLastError() after OrderSend to see trade server return codes. Disable during optimization — Print() does not work then.

Forward testing (or out-of-sample testing) splits historical data: optimize on the first part, then validate on the second. This helps avoid over-fitting — parameters that work on past data may fail on unseen data.

Check: AutoTrading enabled (Ctrl+E), Allow Algo Trading in Options, EA Properties — Allow live trading checked, sufficient margin, symbol in Market Watch, and Expert tab for error messages (e.g. 64 Trade not allowed).

Build your no-code strategy now — free

Create Free Account