History Bridge for MT5 — User guide
Full MetaTrader 5 history for MetaTrader 4 backtests · Jasopex
History Bridge exports the bar history of MetaTrader 5 to MetaTrader 4 history files (.hst) and CSV files, so you can run long MT4 backtests with the same prices you see in MT5. It is a script: it only reads price history and writes files. It never opens, modifies or closes trades.
Quick start
- In MetaTrader 5, go to Tools > Options > Charts, set Max bars in chart to Unlimited and restart the terminal. With a limit, long M1 to M15 histories are cut.
- Open a chart of the symbol. After downloading History Bridge, find it in the Navigator under Scripts > Market and drag it onto the chart.
- Leave the inputs as they are to export the chart symbol, all timeframes and all the history available, or change them (see Input parameters). Press OK.
- Watch the progress card. Long M1 histories can take a few minutes, especially the first time, while MetaTrader 5 downloads the history from the server.
- When the card says Finished, check the table and press Close.
The progress card while M1 is being exported: symbol, timeframe, month and overall progress.
The progress card
- Status line: what is being exported, or the final result (files, bars and items to check).
- Progress bar: overall progress. At the end it turns green if everything is complete, amber if something needs checking and red if a symbol had no data.
- Table: one row per timeframe (one symbol) or one row per symbol (several symbols), with bars, first date, last date and status.
- Folder and tip: where the files are and what to do with them in MT4.
- Stop: stops the export and deletes the files left incomplete. Files already finished are kept.
- Close: removes the card. History Bridge leaves nothing on the chart.
Summary for one symbol: every timeframe with its bars and dates, all marked OK.
Checking the data
A backtest is only as good as its history, so History Bridge checks each timeframe:
- OK: the timeframe covers the range you asked for, or all the history the server has.
- Starts yyyy.mm (amber): the timeframe starts later than the history available on the server. Usually the history was not fully downloaded or Max bars in chart is limited.
- Max bars limit (amber): the timeframe stopped at the Max bars in chart limit.
- No data or Not found (red): there is no history in the range, or the symbol does not exist in this terminal.
When Max bars in chart is limited, an amber line at the top of the card tells you its value. Set it to Unlimited, restart MetaTrader 5 and run History Bridge again.
Several symbols
Write the symbols in Symbols, separated by commas: EURUSD, XAUUSD, GDAXI. If your MT4 account uses another name for a symbol, add it after an equals sign: GDAXI=DE40 creates DE401.hst, DE4060.hst and so on. The card then shows one row per symbol.
Using the files in MetaTrader 4
MetaTrader 5 programs can only write inside MQL5\Files. Open the folder with File > Open Data Folder in MetaTrader 5, then MQL5 > Files > HistoryBridge.
Option 1: .hst files (recommended)
- In MetaTrader 4, go to Tools > Options > Charts and set Max bars in history and Max bars in chart to the maximum.
- In MetaTrader 4, open File > Open Data Folder, then history and the folder with your server name.
- Close MetaTrader 4.
- Copy the .hst files into that folder and replace the existing ones.
- Open MetaTrader 4 and run the backtest with MetaTrader 4 offline, so the server does not replace the history you copied.
Option 2: CSV files
- In MetaTrader 4, open the History Center (F2).
- Select the symbol and a timeframe, press Import and choose the CSV file of that timeframe (for example EURUSD60.csv for H1).
- Repeat for every timeframe. Import them all: a missing or short timeframe causes mismatched chart errors in the tester.
Keep the default CSV options (comma and MT4 date format) for the History Center.
Input parameters
Usually you only need Symbols and, if you want a shorter export, Export from. Start a few months before your backtest so the indicators have previous bars.
General
- Language / Idioma (English): language of the card (English or Spanish).
- Panel theme (Auto): follows the chart background; or force dark or light.
Symbols and dates
- Symbols (empty): empty exports the chart symbol. Otherwise, a list separated by commas; NAME=MT4NAME changes the name used for MT4. Up to 30 symbols.
- Export from (1970.01.01): first date to export. 1970.01.01 means the oldest history available on the server.
- Export to (1970.01.01): last date to export. 1970.01.01 means up to now.
Timeframes
- M1, M5, M15, M30, H1, H4, D1, W1, MN1 (true): timeframes to export. For MT4 backtests, keep at least M1 and the timeframe your Expert Advisor uses.
Output
- Files to create (MT4 history files (.hst) and CSV): .hst and CSV, .hst only or CSV only.
- Subfolder inside MQL5\Files (HistoryBridge): folder for the files. Leave it empty to write directly in MQL5\Files.
- CSV separator (Comma): comma for the MT4 History Center, semicolon or tab for other tools.
- CSV date format (yyyy.mm.dd + hh:mi): MT4 format, with date and time in two columns, or yyyy-mm-dd hh:mi:ss in one column.
- CSV header line (false): adds a first line with the column names. Leave it off for the MT4 History Center.
FAQ
Does it open trades or give signals?
No. It reads the price history of MetaTrader 5 and writes files.
Why can it not copy the files to MetaTrader 4 by itself?
MetaTrader 5 programs from the Market can only write inside MQL5\Files. Copying the files takes a minute and is explained above.
M1 starts much later than H1. Why?
Max bars in chart is limited in MetaTrader 5, or the history was not fully downloaded. Set Max bars in chart to Unlimited, restart MetaTrader 5, open an M1 chart of the symbol, press Home until you reach the start date and run History Bridge again.
Can I use the files with an MT4 account of another broker?
Yes, if both brokers use the same server time and price for the symbol. If not, the backtest will use the MT5 broker's times and prices.
The files are large. Is that normal?
Yes. Eight years of M1 are about 3 million bars: around 180 MB as .hst and a similar size as CSV.
The MT4 history went back to a few months after connecting.
The server replaced it. Copy the files again with MetaTrader 4 closed and run the backtest offline.
Does it work in the Strategy Tester?
No. It is a script that you run on a chart; the files it creates are for the MetaTrader 4 tester.
Results on historical data do not guarantee future results. Trading involves risk.