Loading…

Chart Layout Export And Restore

Rebuilding a multi-chart workspace after a terminal reinstall, a new VPS, or just a crash means reopening every symbol and timeframe by hand, reapplying each chart's template, and redrawing whatever trend lines and levels were marked up on it. Templates alone do not solve this: a .tpl file captures a chart's colour scheme and the indicators attached to it, but it does not capture the objects drawn on the chart - that is a separate list the terminal keeps per chart, and "Save Template" simply does not touch it. This script treats those as two separate jobs, because they are. In export mode it walks every open chart with ChartFirst/ChartNext, calls ChartSaveTemplate for each one, and then separately reads that chart's object list and writes each object's type, anchor points, colour, style, width and text into a manifest. In restore mode it reads the manifest back, opens or reuses a chart per entry, reapplies the saved template, and recreates each object from its saved coordinates. Not every object type has a chart coordinate to save. A few object types - labels, buttons, edit boxes, the rectangle and bitmap label variants - are anchored to a screen corner in pixels, not to a time and a price, because that is what makes them stay in the same place while the chart scrolls underneath them. There is nothing on the chart itself for this script to capture for those, so they are skipped and counted rather than silently dropped: the export summary says exactly how many were left out, so nobody discovers the gap by noticing a missing button days later. Multi-point objects - a Fibonacci fan, a pitchfork, a channel with three anchors - are captured with two points only. Most of what actually gets drawn on a chart in practice is two-point: trend lines, rectangles, horizontal and vertical levels, arrows, text. A three-or-more-point object restores in roughly the right place but not with every anchor exactly where it was; see the notes below for the honest version of that limitation. Notes and limitations - A manifest exported by the MQL4 version encodes the timeframe using MQL4's numbering (plain minutes); the MQL5 version encodes it using MQL5's ENUM_TIMEFRAMES values. The two are not interchangeable - always restore a manifest on the same platform that exported it. See MQL4 VERSUS MQL5 DIFFERENCES. - Objects anchored to a screen corner rather than a chart coordinate - OBJ_LABEL, OBJ_BUTTON, OBJ_EDIT, OBJ_RECTANGLE_LABEL, OBJ_BITMAP_LABEL - are not captured. The export summary reports how many were skipped. - Only the first two anchor points of any object are saved and restored. Two-point objects (trend lines, rectangles, horizontal and vertical lines, arrows, text) round-trip exactly. Objects with more anchors (Fibonacci variants, channels, pitchforks, Gann tools) come back with their first two points correct and the remaining points not restored. - Restoring recreates objects by name, deleting and replacing any existing object of the same name on the target chart first - running a restore twice on the same chart is safe, not additive. - Indicators come back through the saved template exactly as ChartSaveTemplate/ChartApplyTemplate already handle them; this script adds nothing and changes nothing about that part. - Template files are written and read from the terminal's own Templates folder, the same place "Save Template" and "Template" on the chart context menu use - moving a layout between terminals means copying both the manifest from Files and the .tpl files from Templates.

Script · MT4 · v1.0 · Free

About Chart Layout Export And Restore

Chart Layout Export And Restore 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 3 settings, such as Mode, Manifest file and Skip if already open. MQL source code included.

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

Settings

SettingDefaultWhat it does
ModeLAYOUT_EXPORTExport the current layout, or restore a saved one
Manifest fileChartLayout_Manifest.txtManifest file, relative to MQL4\Files
Skip if already opentrueRestore: reuse a chart already open on the same symbol/period

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: Trend · Buy/Sell Arrows · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria