Backtesting workflow
Forex backtesting with realistic spread and timing
Forex backtesting simulates currency-pair rules on historical data with a defined spread, commission, swap, session, order model, and position size. A mid-price chart with zero costs is not enough to support a claim about executable FX returns.
Review the selection checklistChoose the engine that matches the forex strategy
Use MetaTrader 5 Strategy Tester when the deliverable is an MQL5 Expert Advisor that will run in MT5. Use TradingView Strategy Tester when the strategy is expressed in Pine Script and the chart workflow fits the test. The engines use different data, order models, settings, and code runtimes, so matching parameters does not make their results interchangeable.
Model forex-specific costs and sessions
Record the broker or data source, bid and ask treatment, variable or fixed spread, commission, swap, account currency, leverage assumption, and trading hours. Check how weekend gaps and news-period liquidity affect orders. MetaTrader documents tester settings for historical data, tick generation, delays, account settings, commissions, and forward periods; those choices belong with the saved result.
- Preserve symbol specification and account settings.
- Use a spread and cost model appropriate to the test.
- Record tick-generation and execution-delay settings.
Confirm the final rules on unseen data
Repeatedly tuning a currency pair and period can fit one regime. Freeze the EA or Pine Script, run an untouched period, and compare several relevant pairs only when the strategy claim is meant to generalize. Follow with a broker simulation to observe spreads, order rejection, session changes, and execution behavior.
Direct Pineify workflow
Choose the code path before the optimization path
Use MQL5 AI Coding Agent for an MT5 Expert Advisor workflow. If the same idea is implemented as a TradingView strategy, Strategy Optimizer can automate its Pine Script input combinations.
Generate or revise editable MQL5 Expert Advisor source for review and testing in MT5.
Build the MQL5 Expert AdvisorAutomate parameter combinations only when the strategy is implemented in TradingView.
Review the TradingView optimizerBoundary: MQL5 AI Coding Agent does not run MT5 Strategy Tester. Strategy Optimizer works with TradingView, not MetaTrader, so it cannot optimize an MQL5 EA directly.
Primary sources
- MetaTrader 5 Help: How to Test a Trading RobotVerified 2026-08-07
- TradingView Pine Script documentation: StrategiesVerified 2026-08-07
This page is educational and does not provide investment advice. Backtests are hypothetical, depend on their data and assumptions, and do not guarantee future results. Trading can result in substantial loss.