Loading…

TradingView Import Formatter

TradingView's "Import chart data" feature wants one row per bar with a Unix-seconds (or ISO 8601) timestamp column, strictly ascending, with no duplicate or reordered bar. MetaTrader's own History Center export writes a different shape entirely - a separate DATE and TIME column in broker-local text form, tab-separated - so pasting one export straight into the other tool's import dialog simply does not work. A naive column reshuffle would still ship whatever ordering problem already existed in the source file. This formatter checks explicitly: every consecutive pair of output rows must have a strictly increasing timestamp, and if even one row is out of order or duplicated the whole run is refused with a plain message, rather than handing TradingView a file that will silently render bars in the wrong place on the chart. Column positions are configurable rather than hardcoded to MetaTrader's own export shape, so the same script can reformat a differently-shaped bar CSV from another tool without editing the source. Notes and limitations - The script only reformats. It does not fetch or generate bar data itself - a source CSV must already exist in the sandbox. - A row with an unparsable date/time or a high below the low is skipped and counted, not silently written through. - The run is refused entirely, with no output file written, if the source data is not in strictly ascending, duplicate-free time order. Sort or de-duplicate the source file and run again. - Volume is written as a plain integer tick count. TradingView treats an absent or zero volume column as "no volume data" rather than an error, so InpColVolume can be left at -1 for a source with no volume column at all.

Script · MT4 · v1.0 · Free

About TradingView Import Formatter

TradingView Import Formatter is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 12 settings, such as Input file name, Input is tab delimited and Input has header row. MQL source code included.

Files in the download: TradingViewFormatter.mq4, TradingViewFormatter.txt.

Settings

SettingDefaultWhat it does
Input file namehistory_export.csvInput file, from MQL4\Files
Input is tab delimitedtruetrue = tab (MT4 History Center export), false = comma
Input has header rowfalseSkip the first row of the input file
Col date0Column index (0-based) holding the date, e.g. 2024.01.02
Col time1Column index holding the time, e.g. 00:00 (-1 = date column already includes time)
Col open2Column index holding Open
Col high3Column index holding High
Col low4Column index holding Low
Col close5Column index holding Close
Col volume6Column index holding Volume (-1 = no volume column, output 0)
Time outputTimeOutputUnixTimestamp format written to the output file
Output file nametradingview_import.csvOutput file, written to MQL4\Files

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Volume · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria