MetaTrader 4 & 5 — Strategy Tester Backtesting Guide
MetaTrader 4 (MT4) and MetaTrader 5 (MT5) are the most widely used retail trading platforms globally, developed by MetaQuotes Software. Both are free, broker-provided, and include built-in Strategy Testers. MT4 was released in 2005 and still dominates retail forex. MT5 is its multi-asset successor with a significantly more powerful backtesting engine.
Both platforms are free. The Strategy Tester is free. You pay nothing to MetaQuotes — costs come only from broker spreads/commissions.
MQL4 vs MQL5: The Languages
MQL4
C-like procedural language with later OOP extensions. Designed for forex Expert Advisors (EAs).
- C/C++ syntax with trading-specific functions
- Event-driven:
OnTick(),OnInit(),OnDeinit(),OnTimer() OrderSend(),OrderModify(),OrderClose()for trade management- Built-in indicator functions:
iMA(),iRSI(),iMACD(), etc. - DLL imports and WinAPI access
- Well-documented with 20 years of community resources
Difficulty: Intermediate — more verbose than Pine Script but very well-documented.
MQL5
Modern, fully object-oriented C++-like language. Major upgrade over MQL4.
- Full OOP: classes, inheritance, polymorphism, interfaces, templates
- Native multi-symbol access within a single EA
- Built-in matrix/vector operations
- OpenCL support for GPU-accelerated computation
- Python integration (direct calls from MQL5)
- SQLite database access built-in
- ONNX model support for ML integration
- Network functions (HTTP, sockets, WebSocket)
Difficulty: Intermediate-Advanced — steeper curve due to broader API and OOP, but far more capable.
Important: MQL4 and MQL5 are not compatible. MT4 EAs must be rewritten for MT5.
Strategy Tester: MT4 vs MT5
This is where the platforms diverge most. MT5’s Strategy Tester is a generation ahead.
| Feature | MT4 | MT5 |
|---|---|---|
| Threading | Single-threaded | Multi-threaded (all CPU cores) |
| Tick data | Interpolated from M1 bars (poor quality) | Real tick data from broker servers |
| Testing modes | Every tick, Control points, Open prices | Real ticks, Generated ticks, M1 OHLC, Open prices, Math calculations |
| Multi-symbol | No | Yes — single EA can trade multiple instruments |
| Walk-forward | No | Yes — built-in forward testing window |
| Optimization | Genetic algorithm + grid search | Genetic + grid + custom criteria via OnTester() |
| Cloud optimization | No | Yes — MQL5 Cloud Network (thousands of agents) |
| Architecture | 32-bit | 64-bit |
| Timeframes | 9 fixed (M1 to MN) | 21 including custom (M1-MN + M2, M3, H2, H3, H6, H8, H12, etc.) |
| Account models | Hedging only | Hedging and netting |
| Visual testing | Yes | Yes |
MT4 Strategy Tester
Three testing modes:
- Every tick — most accurate but uses interpolated ticks (not real tick data). Slow.
- Control points — fractal interpolation, ~3x faster than every tick.
- Open prices only — fastest; only valid for strategies that trade on bar open.
The biggest MT4 limitation is data quality. Default historical data from the History Center is low quality — M1 bars are interpolated into fake ticks. For reliable results, you need third-party tick data tools like Tick Data Suite or Birt’s Tick Data Manager.
Optimization is single-threaded and slow. Genetic algorithm is available but can’t use multiple cores.
MT5 Strategy Tester
Five testing modes:
- Every tick based on real ticks — highest accuracy; uses broker’s actual recorded tick history
- Every tick (generated) — ticks generated from M1 data
- 1-minute OHLC — faster, less accurate
- Open prices only — fastest
- Math calculations — no chart, pure computation
MT5’s multi-threaded optimizer uses all CPU cores, making it 5-10x faster than MT4 for parameter sweeps. The MQL5 Cloud Network lets you distribute optimization across thousands of remote agents worldwide — useful for strategies with large parameter spaces.
Built-in forward testing splits data into in-sample (optimization) and out-of-sample (validation) windows. This is a form of walk-forward analysis that MT4 completely lacks.
Data Quality
MT4: Poor by default. The History Center provides M1 bars that are interpolated into fake ticks. Results can be misleading. Use third-party tick data for reliable backtests.
MT5: Good. Brokers can provide real recorded tick data. The “every tick based on real ticks” mode uses actual historical ticks — a major advantage for accuracy. However, tick data depth and quality still depends on your broker.
Supported Instruments
MT4: Primarily forex. CFDs on indices, commodities, metals. Stocks and futures limited, broker-dependent.
MT5: True multi-asset — forex, stocks (exchange-traded), futures, options, bonds, ETFs, crypto. MT5 was designed for exchanges, not just OTC forex.
Pricing
Both platforms are completely free. MetaQuotes licenses the platform to brokers; traders pay nothing.
- Platform & Strategy Tester: Free
- MetaEditor IDE: Free (bundled)
- Demo accounts: Free, unlimited
- MQL5 Cloud Network (MT5 only): ~$0.01-0.04 per optimization pass
- VPS: MetaQuotes hosting from ~$10/mo, or third-party
- MQL5.com Marketplace: Paid EAs from $30 to $10,000+
Pros
Both platforms:
- Completely free for backtesting
- Massive ecosystem with thousands of EAs and indicators
- Available from 1,000+ brokers
- Built-in optimization with genetic algorithm
- Visual backtesting mode
- Huge developer community and freelance market
MT5 specifically:
- Multi-threaded optimization (5-10x faster)
- Real tick data backtesting
- Multi-symbol strategy testing
- Built-in forward testing
- Cloud optimization network
- Python and ONNX integration
- 64-bit, 21 timeframes
Cons
MT4:
- Single-threaded, slow optimization
- Poor default tick data quality
- 32-bit, limited RAM
- No multi-symbol testing
- No walk-forward analysis
- No longer actively developed
- Fixed 9 timeframes only
MT5:
- Not backward-compatible with MQL4
- Smaller EA marketplace (growing)
- Fewer brokers (gap is closing)
- More complex learning curve
- No Monte Carlo simulation
- Windows-only natively (Linux/Mac via Wine)
- Cloud optimization costs can add up
Which Should You Choose?
Choose MT4 if: You’re already using it and your broker only offers MT4, or you need specific MT4-only EAs. For new projects, there’s little reason to start with MT4.
Choose MT5 if: You’re starting fresh, need multi-asset support, want real tick data backtesting, or need multi-threaded optimization. MT5 is objectively superior for backtesting in every measurable way.
The industry is gradually migrating to MT5. If you’re learning from scratch, learn MQL5.