Per Position Profit Sparklines
A single P/L number tells you where a trade is, not how it got there. Two positions both sitting at -$20 can have completely different stories - one has been drifting down steadily since it opened, the other spiked to +$60 and has been giving it back for the last hour. This panel keeps a small rolling sparkline of each open position's floating profit so that shape is visible at a glance, next to the ticket, symbol, side and current P/L. MT4 keeps no historical record of an open order's floating profit over time, so there is nothing to query for "yesterday's" shape - this panel samples every open ticket's profit on its own timer (default every 5 seconds) and keeps a bounded, in-memory rolling window per ticket. The history is necessarily empty the moment a ticket first appears and only grows from there; it never shows profit history from before this indicator was running or before the trade was opened, whichever is later. Each sparkline is drawn from small pixel-anchored rectangle objects rather than price/time chart objects, since a sparkline needs to keep its shape regardless of the chart's price scale or zoom level - the same technique documented in this catalogue's SparklineRenderer library, reimplemented directly here because house style forbids one project including another project's file. Notes and limitations Sparkline history starts empty on attach and is lost if the indicator is removed and re-added, or on a terminal restart - it is a live rolling window, not a saved record. A ticket's row and sparkline disappear once that position closes; nothing is kept for closed trades. Sampling runs on a timer independent of tick arrival, so the sparkline shape reflects wall clock time, not tick density.
Indicator · MT4 · v1.0 · Free
About Per Position Profit Sparklines
Per Position Profit Sparklines is an indicator for MetaTrader 4. It has 12 settings, such as Magic filter, Current symbol only and Max positions. MQL source code included.
Files in the download: PerPositionSparklines.mq4, PerPositionSparklines.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Magic filter | -1 | Only show orders with this magic number, -1 = show all |
| Current symbol only | false | Restrict the list to this chart's own symbol |
| Max positions | 12 | Maximum rows shown (also caps memory used for history) |
| History points | 30 | Samples kept per sparkline |
| Sample secs | 5 | Seconds between profit samples |
| Spark width | 90 | Sparkline width, pixels |
| Spark height | 14 | Sparkline height, pixels |
| Row height | 18 | Vertical spacing between rows, pixels |
| Font size | 8 | Row text font size |
| Corner | CORNER_LEFT_UPPER | Panel corner |
| X offset | 10 | Horizontal offset, pixels |
| Y offset | 20 | Vertical offset, pixels |
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 → Indicators.
- 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 indicator from the Navigator onto a chart and adjust the settings.
Tags: MT4 Indicator · MQL4 Source Code