History Timezone Shift Tool
Two brokers rarely run their servers on the same clock. Comparing history side by side, or merging two exports into one series, first needs every timestamp on one side moved onto the other side's clock - and doing that by hand in a spreadsheet, one row at a time, is the kind of job that produces a wrong answer eventually even when it produces a right one ninety-nine times first. The script reads a CSV in the shared six-column schema this catalogue's own Export OHLC script writes - time, open, high, low, close, tick_volume, with time as ISO 8601 - and writes a second file with the same columns and the time field shifted by a constant you choose, in hours, fractional if your two brokers sit half an hour apart rather than a whole one. The shift is a single constant added to every row, deliberately. It does not try to detect a daylight-saving change partway through the file from the spacing of the bars, because that is a guess dressed up as a correction. A broker that changed its server offset mid-export needs the file split at the change and each half shifted on its own; forcing one constant across a DST boundary would silently misalign exactly the rows nearest the switch, which are usually the ones someone is trying hardest to get right. Rows that do not match the expected six-column schema are skipped and counted, never guessed at or dropped silently - the summary states plainly how many rows were written and how many were skipped so nothing goes missing without being noticed. Notes and limitations - Only the six-column schema described above is recognised. A file exported by MetaTrader's own History Center, which uses separate date and time columns, will not match and every row will be skipped - re-export with a tool that writes this schema first. - Daylight-saving changes inside a single file are not detected or handled. Split the file at the change and run the tool twice. - The output file always carries a fresh six-column header, regardless of whether the input file had one. - This is a file transformation only - it never touches the terminal's own loaded chart history.
Script · MT4 · v1.0 · Free
About History Timezone Shift Tool
History Timezone Shift Tool is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Input file name, Output file name and Shift hours. MQL source code included.
Files in the download: HistoryTimezoneShiftTool.ex4, HistoryTimezoneShiftTool.mq4, HistoryTimezoneShiftTool.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Input file name | history_input.csv | File to read, from MQL4\Files |
| Output file name | history_shifted.csv | File to write, into MQL4\Files |
| Shift hours | 0.0 | Hours to add (negative subtracts) |
| Delimiter | DelimiterComma | Column separator, both files |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code