Loading…

Rectangle Zone File Exporter

Traders mark supply/demand or accumulation zones by drawing rectangles on the chart, but that information stays trapped in the chart - no other program can read where a rectangle sits without re-parsing chart objects itself, and most alert or trading tools have no code for that at all. This script exports every OBJ_RECTANGLE on the chart (or every open chart) into one plain CSV file: symbol, zone name, price high, price low, the rectangle's own time start and end, and an expiry timestamp. "Expiry" is not invented - a rectangle already has a later time edge the trader chose when drawing it. That edge is exported as-is, and InpExpiryExtensionHours can add a fixed number of extra hours on top for zones meant to stay valid past their drawn extent, without having to keep redrawing the rectangle wider each day. Every text field is CSV-escaped (quoted, embedded quotes doubled), so zone names containing commas or quotes do not corrupt the file - a detail a naive comma-join export gets wrong the first time someone names a zone "Demand, weekly". Notes and limitations - Only OBJ_RECTANGLE objects are exported. Rectangle labels (OBJ_RECTANGLE_LABEL, a screen-anchored panel background) are a different object type and are not touched. - Read-only: the script never modifies or deletes a rectangle, only reads and writes the CSV. - Re-running with the same InpZonesFile overwrites the previous export in full; it does not append or merge with an older snapshot. - ExpiryTime is computed from the rectangle's own later time edge plus the configured extension - it is not read from anywhere else, since MQL4 rectangles carry no separate expiry property of their own.

Script · MT5 · v1.0 · Free

About Rectangle Zone File Exporter

Rectangle Zone File Exporter is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Zones file, Name prefix filter and Expiry extension hours. MQL source code included.

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

Settings

SettingDefaultWhat it does
Zones fileRectangleZones.csvOutput file, relative to MQL5\Files
Name prefix filterOnly export rectangles whose name starts with this (blank = all)
Expiry extension hours0Extra hours added past the rectangle's own later time edge (0 = none)
All chartsfalseExport rectangles from every open chart, not just this one

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: Supply & Demand · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria