MT5 Architecture for Algotrading
Understand account types, data and modeling, the Strategy Tester, spreads/fees, and logs — to run clean, realistic backtests.
Accounts & Market Data Basics
•Account types: demo vs live; netting vs hedging; leverage and contract sizes influence position sizing and costs.
•History and data quality: ensure sufficient bars and tick history for symbols/timeframes under test.
•Ticks vs minutes: tick-level modeling captures spread and intrabar dynamics; minute OHLC is faster but can distort scalpers.
•Modeling quality: choose the simplest method that does not misrepresent your system's logic.
Accurate intrabar events; slower; recommended for intraday/scalpers.
Pros
- •Captures all intrabar price movements
- •Accurate stop/take-profit triggers
- •Best for scalping strategies
Cons
- •Slowest execution
- •Requires more processing power
- •May not have broker tick data
When to Use
Intraday strategies (M1-H1) with intrabar logic like trailing stops or breakeven.
Strategy Tester: Modeling, Spread, Fees
•Modeling modes: select accuracy based on strategy logic.
•Spread: set fixed spread or 'current' with buffer; spreads widen at rollover/news.
•Commissions/Swaps: include broker-specific round-trip commissions and overnight swaps.
•Multi-scenario tests: change one variable at a time; label runs and compare.
Typical EURUSD spread: 0.5-1.5 pips
ECN brokers typically charge $5-10/lot round-trip
Overnight holding cost; varies by broker and direction
Cost Per Trade
For non-USD pairs, pip value differs — adjust accordingly.
| Spread \ Comm | $0 | $7 | $14 |
|---|---|---|---|
| 0.5 pip | 0.50 pips ($5) | 1.20 pips ($12) | 1.90 pips ($19) |
| 1 pip | 1.00 pips ($10) | 1.70 pips ($17) | 2.40 pips ($24) |
| 1.5 pip | 1.50 pips ($15) | 2.20 pips ($22) | 2.90 pips ($29) |
Color scale: Green ≤1 pip | Amber 1-1.5 pips | Red >1.5 pips
Journals, Logs, and Report Exports
•Journals: Terminal → Toolbox → Journal. Expert logs: Experts tab. Errors (trade context busy, no prices), slippage, requotes appear here.
•Reports: Tester → open completed run → 'Open report' (HTML/CSV) for sharing and analysis.
•Key metrics: Net profit, Profit factor, Max drawdown (abs/rel), Expectancy, Trades, Win rate, Avg trade, Sharpe (if present).
OrderSend OK (ticket 12345678)→ Execution accepted
OrderSend error 4756→ No prices/market closed
Slippage 1.2 points→ Widened spread or latency
Not enough money→ Position sizing exceeded
Modification rejected→ Stop levels too tight
Swap charged -2.34→ Overnight holding costs
Sample Reports
Practice: Your First Clean Backtest
- Install MT5 and open a demo (regulated broker).
- Load history for EURUSD H1 (last 2–3 years).
- Select a sample EA (e.g., 'Moving Average' from MT5 Examples).
- Modeling: Every tick (or Real ticks if available)
- Dates: 24 months IS + 6 months OOS (two runs)
- Spread: 1.0 pip; Commission: $7/lot; Swap: −$1.2/lot/day
- Run IS, then OOS; compare key metrics (PF, Max DD, Expectancy).
- Open HTML and CSV reports; save with labeled filenames.
You can now run basic, realistic backtests and read logs/reports.
Lesson 2 Quiz
Mini-Quiz
Test your understanding with 3 questions. Pass with 2/3 correct.
Educational content only. Not financial advice. Trading involves risk of capital loss. Past performance does not guarantee future results.