Sparkline Renderer
A panel that wants to show the recent shape of a value - equity drifting, spread widening, a correlated symbol moving - normally has two bad options: open a whole extra chart, or print numbers that hide the trend entirely. A sparkline is the third option, and MT4 has no built-in object for it. The reason it is not simply an OBJ_TREND polyline is that a sparkline has to sit in a fixed pixel-sized box in a chart corner, completely independent of the current price scale and visible time range - exactly the opposite of what time/price chart objects are built for. This header draws each sparkline out of a row of thin OBJ_RECTANGLE_LABEL bars instead, the same pixel-anchored primitive MT4's own built-in panels use, so the box stays put and the right size no matter how the chart is scrolled or zoomed. Each bar is normalised to the series' own min and max, so the shape always fills the box whether the underlying values are five-digit prices or four- figure equity numbers, and coloured relative to the previous value - up, down or flat - so a glance tells you the direction as well as the range. Every object gets a caller-supplied prefix, and SparklineRemoveAll clears an entire family of sparklines by that prefix alone, so a panel with several of them can tear the whole set down in OnDeinit with one call. Notes and limitations - A flat series (all values equal) still draws a mid-height bar for every point rather than an empty box, so the widget never disappears silently. - SparklineDraw fully rebuilds the object set on every call rather than moving existing bars - simple and reliable for a panel that redraws on a timer, but avoid calling it every tick on a wide sparkline; redraw on OnTimer or every few seconds instead. - Bars are pixel-anchored to a chart corner, not to price - they do not move when the chart is scrolled, which is the point, not a bug. - No dependency on any indicator buffer or history other than what the caller passes in - equity, spread and any other series must be supplied by the caller, exactly as the demo's synthetic equity curve shows.
Script · MT5 · v1.0 · Free
About Sparkline Renderer
Sparkline Renderer is a script for MetaTrader 5. It has 4 settings, such as Bars, Width and Height. MQL source code included.
Files in the download: SparklineRenderer.mq5.mqh, SparklineRenderer.txt, SparklineRendererDemo.ex5, SparklineRendererDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bars | 40 | Closes to pull for the price sparkline |
| Width | 120 | Sparkline width in pixels |
| Height | 30 | Sparkline height in pixels |
| Display sec | 10 | Seconds to leave the sparklines on the chart |
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: Dashboards & Scanners · Trend · MT5 Script · MQL5 Source Code