Loading…

Tree View Widget

A dashboard listing symbols, strategies, or settings by category usually ends up as one long flat block of labels, because MQL4 has no built-in tree control and no pointers/references to wire real parent-child nodes together safely. This library builds a tree from a flat table instead - each node just records its own id and its parent's id - and recomputes depth and visibility from that table by walking parent links whenever it renders, rather than maintaining a live linked structure. Collapsing a branch hides every descendant, computed by checking that every ancestor up the parent chain is expanded, not just the immediate parent - so collapsing "Majors" also hides a grandchild added under one of its symbols. Rows are plain OBJ_LABEL objects positioned in a stack, indented with leading spaces per depth level and prefixed with a [+]/[-] marker on any row that has children; clicking a parent row toggles it, clicking a leaf row just selects it. Rendering deletes any leftover rows from a previous, longer render so collapsing a branch doesn't leave orphaned label objects behind. This targets a panel-sized tree - tens to a couple of hundred nodes. The flat-table-plus-walk approach is O(depth) per lookup and re-flattens the whole visible list on every Render(), which is the right trade for simplicity and safety at that scale, not a data structure built for a large document tree. Notes and limitations - Rows are plain OBJ_LABEL objects in a vertical stack - there is no scrollbar or clipping for a tree taller than the available panel space; a caller with a very large tree needs to add paging/scrolling of its own on top of this widget. - Depth is shown with leading spaces, not a pixel-based indent offset - simple and reliable, but it means the tree's font must be fixed-width-friendly for the indentation to read cleanly (the default small system font used by OBJ_LABEL works fine for this). - Designed for panel-sized trees (tens to a couple of hundred nodes), not a document-scale hierarchy. - No money is at risk. This library only manipulates chart label objects.

Script · MT4 · v1.0 · Free

About Tree View Widget

Tree View Widget is a script for MetaTrader 4. It shows several symbols in one panel and is set up for gold (XAUUSD). MQL source code included.

Files in the download: TreeViewWidget.mqh, TreeViewWidget.txt, TreeViewWidgetDemo.mq4.

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: Dashboards & Scanners · Gold (XAUUSD) · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria