Gauge And Dial Renderer
A single number buried in a corner label is easy to miss. A gauge with coloured danger zones and a moving needle reads at a glance the way a real dashboard instrument does. MQL4 has no native arc or ellipse object at all, so the ring is approximated with many short OBJ_TREND segments walked around the circle - the same "polygon of trend-line segments" trick this catalogue already uses for synthetic candle wicks, just swept through an angle instead of stacked vertically. The naive version of this converts only the bounding box's two corners to time/price and interpolates inside it, which draws a circle in pixel space as an ELLIPSE in time/price space the moment the chart's time and price axes are not scaled identically pixel-for-pixel - which they never are on a real price chart. This library instead resolves every individual vertex of the ring and needle in pixel space first (centre plus radius*sin/cos at that vertex's own angle) and converts each one separately with ChartXYToTimePrice(), so the rendered shape stays a true circle regardless of how stretched the chart's own axes are. Notes and limitations - The ring is a fixed-segment polygon approximation, not a mathematically smooth arc - arcSegments controls the trade-off between smoothness and the number of chart objects created (default 36 segments). - Render() must be called again whenever the chart is scrolled or zoomed significantly to keep the ring circular; it does not auto-track chart changes on its own. - Zone lookup uses the first matching registered zone in order, so overlapping zone boundaries resolve to whichever was added first. - No money is at risk in the demo. It only displays synthetic sample values and never sends an order.
Script · MT4 · v1.0 · Free
About Gauge And Dial Renderer
Gauge And Dial Renderer is a script for MetaTrader 4. MQL source code included.
Files in the download: GaugeDialRenderer.mqh, GaugeDialRenderer.txt, GaugeDialRendererDemo.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 · Trend · MT4 Script · MQL4 Source Code