Anchor Dock Layout Solver
A dashboard with more than one panel usually hard-codes each panel's pixel offset, which looks fine until the chart window is resized, another panel is added above it, or the terminal opens on a smaller monitor - at which point panels start overlapping or hang off the visible edge. This library separates layout from drawing entirely: it owns no chart objects of its own, only the registered geometry of each panel (which corner it docks to, its margin, its width/height, and the smallest chart size it remains usable at). Solve() reads the chart's current CHART_WIDTH_IN_PIXELS/ CHART_HEIGHT_IN_PIXELS and computes, for every registered panel, a final top-left pixel offset that accounts for the cumulative height of every earlier panel docked to the SAME corner - so three panels registered to one corner stack top-to-bottom automatically in registration order, without the caller doing any arithmetic. A panel whose declared minimum chart size the current chart no longer meets is marked invisible rather than being squeezed into a box too small to read, which is the specific trap a fixed-offset layout has no way to detect at all. The caller reads GetX()/GetY()/IsVisible() after each Solve() and applies them to whatever objects that panel actually owns, so the solver works identically whether the panel underneath is a table, a gauge, or a plain label group. Notes and limitations - This solver stacks along the Y axis only, regardless of which corner a panel is docked to - the common case for a toolbar/panel list running down one side of the chart. It does not do 2D bin-packing or wrap panels into a second column when a corner's stack grows taller than the chart. - Up to 16 panels may be registered at once (ADLS_MAX_PANELS); raise the constant and recompile if a project genuinely needs more. - The solver never creates, moves or deletes a chart object itself - it only computes numbers. Nothing changes on-chart until the caller reads GetX()/GetY()/IsVisible() and applies them. - No money is at risk in the demo. It only computes and prints layout numbers and never sends an order.
Script · MT4 · v1.0 · Free
About Anchor Dock Layout Solver
Anchor Dock Layout Solver is a script for MetaTrader 4. MQL source code included.
Files in the download: AnchorDockLayoutSolver.mqh, AnchorDockLayoutSolver.txt, AnchorDockLayoutSolverDemo.mq4.
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Dashboards & Scanners · MT4 Script · MQL4 Source Code