Loading…

Auto Arrange Charts Grid

Neither MQL4 nor MQL5 exposes a function that moves or resizes a chart's actual window inside the terminal. ChartSetInteger has no settable left/top/width/height property for a normal docked chart - that is confirmed against the official reference, not an oversight in this script. MQL5 later added CHART_FLOAT_LEFT/TOP/RIGHT/BOTTOM, but only for chart windows the trader has already undocked into floating windows, and that property set does not exist on the MQL4 side at all. The only way to move a real window from code is the Windows API (SetWindowPos via user32.dll), which this catalogue's house style forbids outright, and which would need to be trusted with control over windows outside the terminal entirely. Rather than pretend to tile windows it cannot touch, this script does the part of the job that is genuinely scriptable: it works out which open chart belongs in which grid cell, labels each chart with that cell ("GRID R1 C2") using a corner text object, then walks through the charts in order, bringing each to the front for a few seconds so the trader can drag it into its labelled cell while it is the visible window. The manual drag step is the one part with no API - everything else the grid needs is computed and shown automatically. Notes and limitations - This script cannot move, resize or dock/undock a chart window - no MQL4 API exists for that. It assigns cells, labels charts, and guides the manual drag; it does not perform the drag itself. - If more charts are open than the grid has cells, only the first Rows x Columns charts (in the chosen order) receive an assignment; the rest are left untouched and reported as such in the log. - Grid labels are ordinary chart objects prefixed "GridCell_" and can be removed at any time, either via InpRemoveLabelsAtEnd or manually.

Script · MT4 · v1.0 · Free

About Auto Arrange Charts Grid

Auto Arrange Charts Grid is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Rows, Columns and Order by symbol. MQL source code included.

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

Settings

SettingDefaultWhat it does
Rows2Grid rows
Columns3Grid columns
Order by symboltrueAssign cells alphabetically by symbol (false = current window order)
Pause seconds per chart3How long each chart stays brought-to-front during the walkthrough
Remove labels at endfalseDelete the on-chart grid labels once the walkthrough finishes

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: Grid · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria