Skip to content
All library documents

Protecting MQL Chart Objects from Unauthorized Changes and Deletion

Article MQL5 articles

Summary

This beginner-focused article presents ways to respond when chart objects created by an MQL program are changed, deleted, or renamed. It first describes the hidden-object property, which removes an object name from the usual object list while leaving it accessible through the list’s option to show all objects. The article then considers event-driven detection through chart events and explains why checking every object after every event may create unnecessary comparisons, especially on charts with many objects.

Its central implementation idea is a flag system that distinguishes the program’s own object updates from external changes. On detecting interference, a program can either remove itself and clean up its objects or attempt to restore the objects. The article emphasizes non-aggressive responses and offers code-oriented examples and implementation choices. These protections can help maintain a control panel’s consistency, but hidden names are only a preliminary safeguard, and event handling cannot necessarily identify renamed objects without additional checks. The approaches require adaptation to the program’s object lifecycle and performance needs.

Key ideas

  • The hidden-object property removes an object from the standard list but does not make it completely inaccessible.
  • Chart events can signal object creation, deletion, or modification for a program to handle.
  • A flag can distinguish an EA’s own object updates from external changes and reduce unnecessary reactions.
  • Possible responses include restoring chart objects or removing the program and cleaning up its objects.
  • Event-based checks and hidden names have limits, particularly when objects are renamed or many events occur.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.