How to Import Historical Data into MetaTrader 4 & 5
MetaTrader's built-in history is often shallow and broker-dependent. Importing your own clean CSV gives you deeper, consistent data for backtesting expert advisors. Here's how to load it into both MT4 and MT5.

Before you start: get the CSV
Download the instrument and timeframe you need as CSV — for example EUR/USD 1-minute candles. Pick bid or ask to match how you model fills, and note that MetaTrader expects ascending timestamps (oldest first), which our exports already use.
Step zero: give MetaTrader the date and time it expects
MetaTrader's import dialogs read a date column and a time column, such as 2024.01.02,00:00. The app's CSV stores time as a single integer instead — epoch milliseconds in UTC (the format guide explains why) — so convert it once before importing. Five lines of pandas write MetaTrader's layout, with no header row:
import pandas as pd
df = pd.read_csv("eurusd_m1_20240101_20250101.csv")
t = pd.to_datetime(df.pop("timestamp"), unit="ms", utc=True)
df.insert(0, "date", t.dt.strftime("%Y.%m.%d"))
df.insert(1, "time", t.dt.strftime("%H:%M"))
df.to_csv("EURUSD1.csv", header=False, index=False)
The rows stay in UTC. Most MetaTrader brokers run their server clock at UTC+2 or UTC+3, so the imported bars sit two or three hours away from the broker's own chart. That is harmless for most indicators and fatal for an EA with a time-of-day filter: either add the offset in the t line, or write the filter in UTC.
On the Pro licence you can skip all of this for MT4: the MetaTrader export writes a native .hst history file (bars only, 1-minute and up). Rename it to MetaTrader's pattern — EURUSD1.hst for one-minute bars — and copy it into the terminal's history/<server> folder (File → Open Data Folder), with the terminal closed.
MetaTrader 4 — History Center
- Open Tools → History Center (or press F2).
- Select the symbol and timeframe in the left tree, then click Import.
- Choose the converted file, set the separator to comma, and check that the preview shows date, time, open, high, low, close and volume in the right columns.
- Click OK, then refresh the chart. For the Strategy Tester, lower-timeframe data generates the higher ones, so import the finest timeframe you'll test.
MT4 stores history in .hst files; if a broker feed overwrites your import, set the chart's "Max bars in history" high and reconnect after importing.
MetaTrader 5 — Custom Symbols
MT5 replaced the History Center with custom symbols, which is cleaner for imported data:
- Open View → Symbols, click Create Custom Symbol (optionally copying an existing one as a template).
- Select your custom symbol, open the Bars or Ticks tab, and click Import.
- Point it at the converted CSV, set the comma separator, and map the date, time and price fields in the preview before importing.
- Open a chart on the custom symbol and run the Strategy Tester against it.
Tick vs bar import
For "every tick based on real ticks" modelling in MT5, import our tick data into the custom symbol's Ticks tab. Convert the timestamp the same way, keeping milliseconds (%H:%M:%S.%f trimmed to three decimals), and mind the column order: the tick export is timestamp,askPrice,bidPrice,…, ask first, while MT5's tick import lists bid before ask — map by name in the preview, not by position. For faster bar-based backtests, 1-minute candles are usually enough. Grab a file from all instruments and import.
Frequently asked questions
- What CSV format does MetaTrader need?
- Comma-separated, oldest row first, with a date column and a time column (for example 2024.01.02 and 00:00) followed by open, high, low, close and volume. The app's CSV stores time as epoch milliseconds in UTC, so convert that one column first — the guide has a five-line pandas script. On the Pro licence the MetaTrader export writes a native MT4 .hst file instead.
- Why is my MetaTrader history so short or different from the broker?
- Built-in MT4/MT5 history is limited and broker-specific. Importing your own CSV gives deeper, consistent data — useful for backtesting across longer periods and multiple market regimes.
- Can I backtest an EA on imported data?
- Yes. After importing (History Center in MT4, or a custom symbol in MT5), select the symbol/timeframe in the Strategy Tester. Import the finest timeframe you intend to test, since coarser ones are derived from it.
- Should I import tick data or candles into MT5?
- Import tick data into the custom symbol Ticks tab if you need "every tick based on real ticks" modelling; otherwise 1-minute bars are faster and sufficient for most backtests.
Related markets
- Forex Crosses historical data · 55 instruments
- Forex Majors historical data · 7 instruments
Related guides
- Backtesting a Trading Strategy with Historical Data
- Loading Historical Market Data in Python (pandas, Backtrader & VectorBT)
- Querying Historical Market Data with SQL (DuckDB)
- Automating Market Data Downloads
- Importing Historical Data into NinjaTrader 8
- Historical Market Data in Excel & Google Sheets
- How to Use MarketData Hub — The Complete Guide
- Download Gold (XAU/USD) Price History
- Historical Market Data CSV & JSON Format Explained
- Download EUR/USD Price History
- How Far Back Does Historical Market Data Go?