Importing price history
Backtests run on history you bring yourself, usually exported from your own broker’s MetaTrader. That keeps results close to what MetaTrader’s tester shows for the same account, and your data stays private: it is stored for your account only and used only for your backtests.
M1 (one-minute) bars are best. The tester builds every higher timeframe from them and uses them to simulate prices inside each bar.
MetaTrader 5 (recommended)
- On the Market data page, download the export script,
QuantForge_HistoryExport.mq5. - In MetaTrader 5, open File → Open Data Folder → MQL5 → Scripts and copy the script there.
- Press F4 to open MetaEditor, open the script and press Compile (F7). MetaTrader only lists compiled programs.
- Set Tools → Options → Charts → Max bars in chart to Unlimited and restart MetaTrader. Otherwise exports stop at about three months of M1.
- In the Navigator, drag Scripts → QuantForge_HistoryExport onto any chart, enter the symbols (for example
EURUSD,XAUUSD) and the number of years, and press OK. - Back on the Market data page, import the files from MQL5 → Files → QuantForge.
The script writes the symbol’s digits, contract size and broker into each file, so the import needs no extra details.
Without the script
- MetaTrader 5: View → Symbols → Bars, choose M1 and a date range, Request, then Export Bars.
- MetaTrader 4: Tools → History Center, pick the symbol and M1, then Export.
These files carry no contract details, so check the digits and contract size on the review step before importing.
What the importer checks
Before anything is stored you see the detected symbol, timeframe, digits and contract size, and you can correct them. Duplicate bars are dropped, unreadable rows are reported, and gaps of an hour or more during trading days are listed so you can judge them. History is stored month by month; importing the same symbol again merges the new months in.
Spread
MetaTrader’s exports include the spread of each bar, and the tester uses it by default. Histories without a spread column use the fixed spread set in the tester.