Object Count Guard
Chart objects are cheap one at a time, but a tool with a bug (or just an aggressive drawing style - one rectangle per bar, one label per signal) can quietly leave thousands of them on a chart over a long session, and the first symptom is usually just "the chart feels slow" with no obvious cause. By the time that is noticed, finding which tool is responsible means detaching things one at a time and hoping the slowdown goes away. This indicator groups every chart object by its name prefix (the text before the first delimiter, "_" by default - the same naming convention this catalogue's own indicators use for their own objects) and totals a count per group, refreshed on a timer. Each group is colour-banded against a warn/critical threshold, the chart-wide total gets its own threshold pair, and a critical breach fires a cooldown-limited alert rather than a one-time warning that can be missed. MQL4 has no API to ask "which program owns this object", only its name - prefix grouping is a convention-based proxy, not a guarantee. Two unrelated tools sharing a prefix are counted as one group, and a tool that does not prefix its objects at all falls into the catch-all "(no prefix)" bucket. This is stated plainly rather than implied to be a precise attribution. Notes and limitations - Prefix grouping is a naming convention, not a real ownership record - see full description. Two tools sharing a prefix, or a tool using no prefix at all, will not be attributed correctly. - This guard's own panel objects are excluded from every count so it never reports on itself. - Read-only: it warns and alerts but never deletes anyone else's objects. - Rescans the entire object list every refresh (default every 2 seconds); on a chart that already has an extremely large object count, the scan itself adds a small amount of load, which is an unavoidable trade-off for a guard that has to check the very thing it warns about.
Indicator · MT4 · v1.0 · Free
About Object Count Guard
Object Count Guard is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 16 settings, such as Prefix delimiter, Warn per prefix and Critical per prefix. MQL source code included.
Files in the download: ObjectCountGuard.mq4, ObjectCountGuard.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Prefix delimiter | _ | Character that splits "owner prefix" from the rest of an object name |
| Warn per prefix | 150 | Objects in one prefix group that trigger a warning colour |
| Critical per prefix | 300 | Objects in one prefix group that trigger a critical colour + alert |
| Warn total | 500 | Chart-wide total object count that triggers a warning |
| Critical total | 1000 | Chart-wide total object count that triggers a critical alert |
| Max rows shown | 10 | Largest N prefix groups drawn on the panel |
| Alert cooldown seconds | 300 | Minimum seconds between repeat critical alerts |
| Refresh seconds | 2 | Panel refresh interval |
| Corner | CORNER_LEFT_UPPER | ENUM_BASE_CORNER |
| X offset | 8 | |
| Y offset | 16 | |
| Row height | 14 | |
| Ok color | clrLimeGreen | Colour on the chart |
| Warn color | clrOrange | Colour on the chart |
| Critical color | clrRed | Colour on the chart |
| Header color | clrWhiteSmoke | Colour on the chart |
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: Buy/Sell Arrows · Trading Sessions · Alerts · MT4 Indicator · MQL4 Source Code