Loading…

Progress And Spinner Widgets

CProgressBarWidget draws two rectangles: a fixed background track and a second fill rectangle layered on top, sized to percent-of-track-width. SetPercent() only ever resizes the fill rectangle's OBJPROP_XSIZE - it never deletes and recreates the object - which is what keeps a bar that updates on every tick from visibly flickering, and it is the same reason the track and fill are two separate objects rather than one object redrawn from scratch each call. CSpinnerWidget cycles through a short list of glyphs on an interval, but it deliberately owns no timer of its own. Update() takes the caller's own GetTickCount() reading and only advances the frame once the configured interval has genuinely elapsed since the last advance - a host program that calls Update() on every OnTick, dozens of times a second, still only sees the glyph change at the configured rate, and a single shared OnTimer/OnTick can drive any number of independent spinner instances this way without each one needing to register its own EventSetTimer. The elapsed-time subtraction is done in unsigned arithmetic specifically so it keeps giving the correct answer across GetTickCount()'s roughly-49.7-day wraparound, not just during a session that started recently. Notes and limitations - CSpinnerWidget never advances on its own - a host program that stops calling Update() (e.g. it only runs OnTick and the market is closed) simply leaves the spinner showing its last frame, which is the correct behaviour for a "busy while something is happening" indicator, not a defect. - The progress bar has no percentage text label of its own; a caller wanting a "45%" readout should add its own OBJ_LABEL alongside the bar, since not every use of a progress bar wants text overlaid on it. - Frame glyphs are plain text, not bitmap icons - fine for a spinner ("|/-\\") or short status words, not for a graphical icon set. - No trading and no money at risk - the demo only exercises the widgets' drawing and update logic, it never sends an order.

Script · MT5 · v1.0 · Free

About Progress And Spinner Widgets

Progress And Spinner Widgets is a script for MetaTrader 5. It has 1 setting, such as Prefix. MQL source code included.

Files in the download: ProgressSpinnerWidgets.mq5.mqh, ProgressSpinnerWidgets.txt, ProgressSpinnerWidgetsDemo.ex5, ProgressSpinnerWidgetsDemo.mq5.

Settings

SettingDefaultWhat it does
PrefixPSWDemo_Object-name prefix for this demo's widgets

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria