Loading…

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

SettingDefaultWhat it does
Prefix delimiter_Character that splits "owner prefix" from the rest of an object name
Warn per prefix150Objects in one prefix group that trigger a warning colour
Critical per prefix300Objects in one prefix group that trigger a critical colour + alert
Warn total500Chart-wide total object count that triggers a warning
Critical total1000Chart-wide total object count that triggers a critical alert
Max rows shown10Largest N prefix groups drawn on the panel
Alert cooldown seconds300Minimum seconds between repeat critical alerts
Refresh seconds2Panel refresh interval
CornerCORNER_LEFT_UPPERENUM_BASE_CORNER
X offset8
Y offset16
Row height14
Ok colorclrLimeGreenColour on the chart
Warn colorclrOrangeColour on the chart
Critical colorclrRedColour on the chart
Header colorclrWhiteSmokeColour on the chart

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Buy/Sell Arrows · Trading Sessions · Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria