Loading…

Export Chart Objects To File

A chart built up over weeks of analysis - support and resistance lines, supply zones, annotated trend lines - lives only in that one chart's template unless it is written out somewhere else. Templates are also per-chart and per-terminal, so they do not survive a symbol change, a rebuilt terminal, or handing the setup to someone else. A plain text export fixes all three: it opens in anything, diffs cleanly, and can be regenerated onto a fresh chart later. The trap in a script like this is not the writing, it is the objects it cannot write. MetaTrader draws more than two dozen object types, and a fixed CSV schema can only describe the handful that reduce to a couple of price and time anchors: a horizontal line, a vertical line, a trend line, a rectangle, a text label. An arrow, a Fibonacci tool, a channel, a button or a bitmap needs different columns entirely, and bolting them onto the same file either breaks the schema or silently corrupts the file the moment one shows up. The dishonest fix is to just skip them without saying so - the chart looks exported, the file looks complete, and three weeks later someone notices half the Fibonacci retracements never came back after a rebuild. This script names the trap instead of hiding it: every object it cannot write is printed to the journal with its type and its name, and the closing alert gives a count of what was skipped alongside what was exported, so nothing goes missing quietly. This script is one half of a round trip. Its companion, "Import CSV As Chart Objects" (catalogue S069), reads a file in exactly this schema back onto a chart and recreates the five supported object types. Run this script on the chart you want to preserve, keep the CSV, then run the companion script - on the same chart, a different chart, or after a rebuild - to bring the drawings back. Notes and limitations - Only five object types round-trip through this schema: horizontal line, vertical line, trend line, rectangle and text label. Every other object type - arrows, all of the Fibonacci tools, channels, Gann tools, the pitchfork, buttons, bitmaps, edit boxes and labels anchored to a chart corner - is reported as "not exported" in the journal with its type and name, and is not written to the file. - Only objects on the main chart (window 0) are read. An object drawn on an indicator subwindow, such as one pinned to an oscillator's own price scale, is not included - its price anchor belongs to a different scale and would not mean the same thing back on the main window. - The text content of a TEXT object is not captured as a separate column. The schema's "name" field is the object's own name for every type, including TEXT, so if the object was never given a meaningful name the round trip preserves its position and colour but not a caption. - Re-running the script overwrites the output file; it does not append. - The file is written to the Files sandbox, not an arbitrary path on disk. Move or copy it from there if it needs to travel further.

Script · MT4 · v1.0 · Free

About Export Chart Objects To File

Export Chart Objects To File is a script for MetaTrader 4. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 1 setting, such as File name. MQL source code included.

Files in the download: ExportChartObjects.ex4, ExportChartObjects.mq4, ExportChartObjects.txt.

Settings

SettingDefaultWhat it does
File namechart_objects.csvOutput file, written under 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: Support & Resistance · Trend · Buy/Sell Arrows · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria