Lesson 10 of 16intermediate12 min readLast updated March 2026

Importing Data into MT5

Loading custom historical data and symbol data into MetaTrader 5.

Key Terms

data import·historical data·custom symbol·CSV import

MetaTrader 5 automatically downloads historical price data from your broker's trade server when you open a chart. For most trading purposes, this broker-provided data is sufficient, it covers the instruments offered by your broker across all available timeframes and is updated continuously as new price data forms. However, there are situations where you need to go beyond the data your broker supplies. You may want to import historical data from an independent data provider for more thorough backtesting, load tick-level data for precise strategy optimization, create custom symbols that your broker does not offer, or supplement gaps in your broker's historical record.

MetaTrader 5 provides two primary mechanisms for importing external data: the History Center (for importing bar data into existing symbols) and Custom Symbols (for creating entirely new instruments with your own data). This lesson covers both approaches in detail, walking through file format requirements, the step-by-step import process, common pitfalls and error handling, and practical applications of imported data in backtesting and analysis.

Understanding MT5's Data Architecture

Before importing data, it helps to understand how MT5 organizes price information internally.

Data hierarchy in MT5:

MT5 stores all price data as M1 (1-minute) bars or tick data. Higher timeframe bars (M5, M15, H1, H4, D1, W1, MN) are not stored independently, they are calculated dynamically from the M1 data. This means:

  • When you import M1 bar data for a symbol, MT5 automatically constructs all higher timeframes from that data.
  • You do not need to import separate files for each timeframe.
  • The quality and completeness of your M1 data directly determines the accuracy of all higher timeframes.

Tick data versus bar data:

  • Bar data (OHLCV): Consists of Open, High, Low, Close, and Volume values for each time period. M1 bar data provides one data point per minute of market activity.
  • Tick data: Records every individual price change, potentially hundreds or thousands of ticks per minute during active sessions. Tick data provides the highest possible resolution and is particularly important for backtesting strategies that operate on very short timeframes or those that are sensitive to spread and slippage.

MT5 supports importing both formats, though the process differs for each.

Importing Historical Bar Data via the History Center

The History Center is MT5's built-in data management tool. It allows you to view, edit, and import historical bar data for any symbol available in your Market Watch.

Step 1, Open the History Center:

Press F2 or navigate to Tools > History Center from the menu bar. The History Center window displays a tree structure of all available symbols organized by market category (Forex, CFDs, Futures, etc.).

Step 2, Select the target symbol and timeframe:

  1. Expand the appropriate category in the left panel.
  2. Select the symbol you want to import data for (e.g., EURUSD).
  3. Select the timeframe. For the most flexibility, choose M1 (1-minute) since MT5 will calculate all higher timeframes from M1 data.
  4. The right panel will display the currently stored data for that symbol and timeframe.

Step 3, Prepare your data file:

MT5's History Center accepts data in CSV (comma-separated values) format. The file must follow a specific structure:

Date,Time,Open,High,Low,Close,TickVolume,RealVolume,Spread
2024.01.02,00:00,1.10450,1.10465,1.10440,1.10460,125,0,2
2024.01.02,00:01,1.10460,1.10475,1.10455,1.10470,98,0,2
2024.01.02,00:02,1.10470,1.10480,1.10460,1.10475,112,0,3

Required columns (in order):

ColumnFormatDescription
DateYYYY.MM.DDThe date of the bar
TimeHH:MMThe time of the bar (in the server's timezone)
OpenDecimalThe opening price of the bar
HighDecimalThe highest price during the bar
LowDecimalThe lowest price during the bar
CloseDecimalThe closing price of the bar
Tick VolumeIntegerThe number of ticks during the bar period
Real VolumeIntegerThe real traded volume (often 0 for forex)
SpreadIntegerThe spread in points at the time of the bar

Important formatting notes:

  • The decimal separator must be a period (.), not a comma.
  • The date format must be YYYY.MM.DD, other formats (DD/MM/YYYY, MM-DD-YYYY) will cause import failures.
  • The time must be in 24-hour format (HH:MM), not 12-hour format with AM/PM.
  • If your source data does not include Tick Volume, Real Volume, or Spread, you can use 0 as a placeholder.
  • Ensure there is no trailing comma at the end of each line.
  • The file encoding should be UTF-8 or ANSI.

Step 4, Import the data:

  1. In the History Center, with the correct symbol and timeframe selected, click the "Import" button (or right-click and select "Import").
  2. A file selection dialog will appear. Navigate to your prepared CSV file and select it.
  3. MT5 will display a preview of the data to be imported, showing the first several rows.
  4. Verify the preview looks correct, dates, times, and prices should align with the column headers.
  5. Click "OK" to begin the import.
  6. MT5 will process the file and merge the imported data with any existing data for that symbol.

Creating and Importing Data for Custom Symbols

Custom symbols are instruments that you create manually in MT5, independent of your broker's symbol list. This feature allows you to chart and analyze instruments your broker does not offer, create synthetic instruments (such as custom indices or spread charts), or import historical data for educational and analytical purposes.

Step 1, Create the custom symbol:

  1. Open the Market Watch panel (Ctrl + M).
  2. Right-click anywhere in the Market Watch and select "Symbols" (or press the corresponding toolbar button).
  3. In the Symbols dialog, click "Create Custom Symbol."
  4. Enter the symbol name (e.g., "USDCNY_CUSTOM" or "SP500_HISTORICAL").
  5. Configure the symbol properties:
    • Symbol path: Choose or create a group folder for organization.
    • Description: A human-readable description of the instrument.
    • Digits: The number of decimal places for price display (5 for most forex pairs, 2 for indices, etc.).
    • Contract size: The standard lot size (typically 100,000 for forex).
    • Profit calculation mode: Select "Forex" for currency pairs or "CFD" for indices and commodities.
    • Margin calculation mode: Select the appropriate mode for the instrument type.
    • Tick size: The minimum price increment (e.g., 0.00001 for a 5-digit forex pair).
    • Tick value: The monetary value of one tick movement per standard lot.
  6. Click "OK" to create the symbol.

Step 2, Import data into the custom symbol:

  1. In the Symbols dialog, select the custom symbol you just created.
  2. Click the "Bars" tab at the bottom of the dialog.
  3. Click "Import Bars" to import OHLCV bar data.
  4. Select your prepared CSV file.
  5. Verify the import preview and click "OK."

Alternatively, for tick data:

  1. Select the custom symbol in the Symbols dialog.
  2. Click the "Ticks" tab.
  3. Click "Import Ticks."
  4. Select the tick data CSV file (format: Date, Time, Bid, Ask, Last, Volume, Flags).
  5. Verify and confirm the import.

Step 3, Add the custom symbol to Market Watch:

  1. In the Market Watch panel, right-click and select "Symbols."
  2. Find your custom symbol in the list.
  3. Select it and click "Show" to make it available in Market Watch.
  4. Close the dialog. The custom symbol now appears in Market Watch and can be opened as a chart.

Preparing Data from Common External Sources

Different data providers supply data in different formats. Here is how to prepare data from several popular sources:

From Dukascopy (Swiss FX Marketplace):

Dukascopy provides free historical tick and bar data through its online data portal. Downloaded data typically comes in CSV format but may require adjustments:

  • Column order may differ from MT5's expected format, reorder columns in a spreadsheet application before importing.
  • Dukascopy uses GMT timezone by default. If your broker's server uses a different timezone, you may need to adjust the timestamps.
  • Decimal format usually matches MT5 requirements (period as separator).

From HistData.com:

HistData.com provides free M1 bar data in several formats. For MT5 import:

  • Download the "ASCII" format, which provides data in CSV with semicolon separators.
  • You will need to replace semicolons with commas and ensure the date/time format matches YYYY.MM.DD and HH:MM.
  • HistData provides separate files for each month, you may want to combine these into a single file before importing.

From TrueFX:

TrueFX provides tick-by-tick data in CSV format:

  • The data format includes timestamp, currency pair, bid, and ask columns.
  • This format is suitable for importing as tick data into custom symbols.
  • Convert the timestamp format to match MT5 requirements if necessary.

General data preparation workflow:

  1. Download raw data from your chosen source.
  2. Open the file in a spreadsheet application (Excel, Google Sheets, LibreOffice Calc) or a text editor.
  3. Reorder columns to match MT5's expected format.
  4. Adjust date and time formats.
  5. Replace decimal separators if needed (comma to period).
  6. Remove any header rows (MT5 may misinterpret headers as data, causing errors).
  7. Save as CSV with comma separators and UTF-8 encoding.
  8. Verify the file by opening it in a text editor to confirm proper formatting.

Verifying Imported Data

After importing, always verify that the data loaded correctly:

Visual verification:

  1. Open a chart for the imported symbol (or the symbol whose data you updated).
  2. Switch to the M1 timeframe (Alt + 1).
  3. Scroll through the data and look for:
    • Gaps where bars are missing (flat sections or jumps in the time axis).
    • Price spikes or anomalies that seem inconsistent with normal market behavior.
    • Consistent pricing throughout the dataset (no sudden order-of-magnitude shifts).
  4. Switch to higher timeframes (H1, D1) to verify the data looks reasonable at broader perspectives.

Numerical verification:

  1. Open the History Center (F2) and select the symbol and timeframe.
  2. Check the date range of the available data, it should include the dates you imported.
  3. Compare specific bars against the original source data to confirm prices match.
  4. Check the bar count, it should be consistent with the expected number of bars for the date range and timeframe.

Common issues to watch for:

  • Timezone misalignment: If imported data uses a different timezone than your broker's server, bars will appear shifted. This creates inaccurate higher timeframe bars (for example, daily bars opening and closing at the wrong time).
  • Duplicate bars: If the same timestamp exists in both existing and imported data, the imported values overwrite the existing ones. This is usually desirable but can be problematic if the imported data is less accurate.
  • Missing weekend data: Forex markets are closed on weekends, so gaps from Friday evening to Sunday evening are normal, do not attempt to fill these.
  • Holiday gaps: Data gaps on major holidays (Christmas, New Year) are also normal.

Practical Applications of Imported Data

Extended backtesting:

The most common reason for importing external data is to extend the backtesting period beyond what your broker provides. If your broker offers only three years of EUR/USD history but you want to test a strategy over 15 years of data (covering multiple economic cycles, crises, and trend regimes), importing external data makes this possible.

  1. Create a custom symbol (e.g., "EURUSD_EXTENDED").
  2. Import 15 years of M1 data from an external source.
  3. Open the Strategy Tester (Ctrl + R) and select your custom symbol for testing.
  4. Configure the test period to cover the full 15-year range.

Cross-broker data comparison:

By importing data from a different broker or data provider into a custom symbol, you can compare it side-by-side with your current broker's data. This can reveal differences in spreads, price gaps, and data completeness that may affect strategy performance.

Custom synthetic instruments:

Custom symbols allow you to create instruments that combine or transform existing data:

  • A custom index tracking the average of multiple currency pairs.
  • A spread chart showing the price difference between two related instruments.
  • A data series from a market or exchange that your broker does not cover.

Creating synthetic instruments requires additional data manipulation (combining or calculating values from multiple source files) before importing into MT5.

Managing Storage and Performance

Imported data occupies disk space and can affect MT5 performance if the dataset is very large.

Storage considerations:

  • M1 bar data for one forex pair spanning 10 years occupies approximately 200-400 MB uncompressed. MT5 compresses stored data, reducing the actual disk usage.
  • Tick data is significantly larger, one year of tick data for an active forex pair can be several gigabytes.
  • Custom symbols with imported data are stored in the MT5 data folder under MQL5/Files or the custom symbol storage directory.

Performance impact:

  • Loading charts with very large datasets (millions of bars) can cause slower chart scrolling and longer indicator calculation times.
  • Reduce the "Max bars in chart" setting (Tools > Options > Charts) if performance degrades.
  • For backtesting, the Strategy Tester loads only the data needed for the specified test period, mitigating performance concerns for very long histories.

Maintaining data integrity:

  • Keep backup copies of your original imported data files in a separate folder outside MT5's data directory.
  • If you need to re-import or correct data, having the original source files prevents the need to re-download from external providers.
  • Document what data you imported, from which source, and when, this is important for reproducing backtesting results and understanding any data-dependent analysis.

Key Takeaways

  • MT5 builds all timeframes from M1 data. Importing M1 bar data gives you automatic access to all higher timeframes, so you only need to import one timeframe.
  • CSV format must follow MT5's exact specifications. Date format (YYYY.MM.DD), time format (HH:MM), decimal separator (period), and column order must all be correct, or the import will fail.
  • Custom symbols allow importing data for any instrument. You can create symbols that your broker does not offer, enabling analysis and backtesting of external datasets.
  • Always verify imported data visually and numerically. Check charts for gaps, spikes, and anomalies, and compare sample bars against the original source to confirm accuracy.
  • Timezone alignment is critical. Imported data must use the same timezone as your broker's server, or daily and weekly bars will be calculated incorrectly.
  • External data extends backtesting capabilities. Importing 10 to 15 years of history from independent data providers enables strategy testing across multiple market regimes and economic cycles.
  • Back up original data files. Keep copies of your source CSV files outside MT5's directory for future re-imports, corrections, or documentation of your testing methodology.

This lesson is for educational purposes only. It does not constitute financial advice. Trading forex involves significant risk of loss and is not suitable for all investors.

Sign up to read this lesson

Create a free account to start reading. Get 5 free lessons every month, or upgrade to Pro for unlimited access.