Loading…

Export Tick Stream To CSV

Tick-level data is what backtests and execution research actually need, and it is the one thing MetaTrader 4 and MetaTrader 5 disagree about at the most fundamental level: MT5 keeps a genuine tick history you can query for any past date, and MT4 does not keep one at all - what you see on the chart right now is all there has ever been, from the platform's point of view. The MQL5 version pulls that real history with CopyTicksRange(), a fixed number of days back from now. Asking for a month or more of ticks on a busy symbol in one call is a serious amount of memory - potentially millions of rows - so this script requests one calendar day at a time, writes that day straight to the file, and reports progress in the log as it goes. A day that fails to return data is retried once, then logged as failed and skipped, rather than aborting the whole export over one bad day. The MQL4 version cannot do any of that, because there is nothing to query. Rather than pretend otherwise, it becomes a live capturer: for a duration you set, it polls the symbol's price and writes a row every time bid, ask or last actually changes. This is an honest sample of what happened while the script was running on your machine, not a historical record you can request for yesterday. See the platform notes below for exactly what that means in practice. Notes and limitations - MQL5: a day with no ticks (a weekend, a public holiday) is not an error and is logged as zero ticks, not skipped silently. - MQL5: requesting a symbol MetaTrader has not cached tick history for yet can trigger a server fetch; if a day still fails after one retry it is logged as failed and the export continues with the next day. - MQL4: the "last" column is broker- and instrument-dependent. Many spot FX symbols never populate it and it will read 0.0 for the whole capture - that is the feed, not a bug in the script. - MQL4: closing the chart, removing the script, or waiting out the full duration are the only ways this stops; there is no way to pause and resume a capture. - Both versions write with the symbol's own digit count, so a JPY pair and a 5-digit majors export correctly side by side.

Script · MT5 · v1.0 · Free

About Export Tick Stream To CSV

Export Tick Stream To CSV is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Symbol, Days and Delimiter. MQL source code included.

Files in the download: ExportTicks.ex5, ExportTicks.mq5, ExportTicks.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol ("" = this chart's symbol)
Days1Days of tick history to export, back from now
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria