Table Grid Widget
A hand-laid grid of labels is easy to draw and immediately stops scaling the moment the data behind it needs sorting or does not fit on screen at once. This widget separates the data from the display: SetCell() writes into a row-major buffer sized rows*columns independently of how many rows are actually visible, and a separate permutation array maps each visible display row back to its underlying data row. Clicking a header button rebuilds that permutation (ascending, or reversed if the same column is clicked again) and Render() redraws only the fixed-size visible window - the widget creates exactly visibleRows*columns chart objects at Create() time and never creates or destroys a single object per row of data afterward, so a 500-row table costs exactly as many chart objects as a 10-row one, just a different scroll range. Column "formatting" is a per-column optional decimal count: when set, a cell is parsed as a number and re-rendered with that many decimals at display time, while the underlying stored text is left exactly as supplied - both sorting and formatting read from the same stored string, they just interpret it differently, so a numeric column sorts correctly even before it has ever been displayed with its formatting applied. Notes and limitations - Sorting is O(rows^2) insertion sort, the right trade for the dashboard-sized tables (tens to low hundreds of rows) this widget targets in exchange for code with no partitioning logic to get wrong. - All stored cell values are plain strings; numeric formatting and numeric sorting are both opt-in per column and both parse the stored string at the point of use rather than keeping a separate typed copy. - Row selection (clicking a data row, not just a header) is not implemented - DisplayRowToDataRow() is exposed so a caller can layer that on top by tracking row-cell object clicks itself. - No horizontal scrolling - columns are laid out left to right at their configured widths with no clipping or wrapping if the total exceeds the chart width. - No money is at risk in the demo. It displays a synthetic symbol list only and never sends an order.
Script · MT4 · v1.0 · Free
About Table Grid Widget
Table Grid Widget is a script for MetaTrader 4. It shows several symbols in one panel. MQL source code included.
Files in the download: TableGridWidget.mqh, TableGridWidget.txt, TableGridWidgetDemo.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: Grid · Dashboards & Scanners · MT4 Script · MQL4 Source Code