Label And Text Widget
OBJ_LABEL already renders embedded "\n" as separate lines on both platforms. Most home-grown panels do not use this and instead stack three or four separate label objects to show a multi-line block, which means three or four names to track, move and delete instead of one. This wrapper leans on the native line-break support rather than reinventing layout, so a status readout - balance, equity, margin - is one CLabelWidget with one string. SetTextAndColor() exists for the specific case a trading panel hits constantly: a value label whose colour should follow its sign, such as a floating P/L readout that goes green in profit and red in loss. Without it, every call site repeats the same SetText-then-SetColor pair; with it, the colour decision is made once, at the call site that has the value, not scattered through the panel's update loop. SetVisible() toggles OBJPROP_TIMEFRAMES between OBJ_ALL_PERIODS and OBJ_NO_PERIODS rather than deleting and recreating the object, which is cheaper when a label is shown and hidden repeatedly - a collapsed panel section, for instance. The header is self-contained - one class, no dependency on WidgetEdit, ChartObjects or PanelFramework from this collection. Notes and limitations - OBJ_LABEL does not wrap text automatically. A line longer than the visible chart width is simply clipped; insert your own "\n" breaks at the point you want a line to end. - Font metrics are not queried, so there is no auto-sizing background box - this widget draws text only, not a filled backdrop behind it. - One widget instance owns exactly one chart object. A multi-line block belongs in one CLabelWidget; use a separate instance only for genuinely independent pieces of text that move or update on their own.
Script · MT5 · v1.0 · Free
About Label And Text Widget
Label And Text Widget is a script for MetaTrader 5. It has 1 setting, such as Prefix. MQL source code included.
Files in the download: WidgetLabel.mq5.mqh, WidgetLabel.txt, WidgetLabelDemo.ex5, WidgetLabelDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Prefix | WidgetLabelDemo_ | Object-name prefix, avoids collisions on re-run |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: MT5 Script · MQL5 Source Code