QuantForge
en

How to backtest an EA on your own broker's M1 data

Export M1 history from MetaTrader 4 or 5, import it, and backtest an Expert Advisor with realistic spread, commission and slippage. Then repeat the run in MetaTrader to compare.

Start freeRead the docsFree plan, no card needed.

Updated 5 November 2026

A backtest is only as good as its data and its costs. This guide gets your broker’s M1 history out of MetaTrader, into QuantForge, and through a backtest with realistic costs.

1. Export the history from MetaTrader

The quickest way on MetaTrader 5 is the free export script:

  1. In QuantForge, open Market data and download QuantForge_HistoryExport.mq5.
  2. In MetaTrader 5, File → Open Data Folder → MQL5 → Scripts, copy the script there, open it in MetaEditor (F4) and press Compile.
  3. Set Tools → Options → Charts → Max bars in chart to Unlimited and restart MetaTrader.
  4. Drag the script onto any chart, enter the symbols (for example EURUSD,XAUUSD) and the number of years.

The files land in MQL5 → Files → QuantForge, with the symbol’s digits, contract size and broker written in. Without the script, use View → Symbols → Bars → Export Bars on MetaTrader 5, or Tools → History Center → Export on MetaTrader 4. The data docs cover every option.

2. Import it

Drop the files on the Market data page. Before anything is stored you see the symbol, timeframe, digits and contract size, the duplicate bars dropped, and any gaps of an hour or more on trading days. Fix the details if needed and import. The data is stored privately for your account.

3. Set realistic costs

In the Strategy Tester’s Setup:

  • Spread: taken from the history when it has a spread column (MetaTrader exports do).
  • Commission: in USD per lot, charged when the trade opens and again when it closes. Raw-spread accounts often cost about $7 per lot round turn, so enter 3.5.
  • Slippage: 0.5 to 1 pip on market orders for liquid pairs, more for gold and indices.
  • Swap: your broker’s values in points per lot, if the strategy holds overnight.
  • Account: hedging or netting, as your MetaTrader 5 account.

Pick the 1-minute OHLC model for anything that uses stops, trailing or intraday entries. Open prices only is fine, and much faster, for strategies that act only once per bar.

4. Read the results, then check in MetaTrader

Read the report’s warnings box first: it lists anything that could make results differ from a live account. Then the equity curve, the drawdown, the monthly returns and a few individual trades on the chart.

To confirm, use the report’s MT5 tester .ini and inputs .set buttons and repeat the run in MetaTrader 5’s Strategy Tester. Expect small differences, because MetaTrader generates more ticks inside each minute. Large differences usually mean different data, costs or inputs.

Next: avoid over-fitting with forward tests and Monte Carlo.

Frequently asked questions

Why use my broker's data instead of a public data set?

Prices, spreads and server time zones differ between brokers. Testing on the history of the broker you'll trade with keeps the backtest closer to what the EA will see live, and to what MetaTrader's own tester shows for that account.

How many years of M1 data do I need?

At least as much as covers different market conditions: two years is a reasonable minimum for intraday strategies, more for strategies that trade a few times a month. Keep the last part aside as a forward test.

Why does MetaTrader only export three months of M1?

MetaTrader limits the bars kept in charts. Set Tools → Options → Charts → Max bars in chart to Unlimited and restart the terminal before exporting.

Build your first EA today

The free plan includes three projects, backtests on H1 to D1 over a year, MQL4/MQL5 export and the converter.

Start free

Keep exploring