MQL5 Z-Order and Interactive Position-Level Lines
Summary
This article explains how the Z-order property affects selection and interaction among overlapping chart objects in MetaTrader 5. Using chart objects as an example, it shows that the order in which objects are drawn does not necessarily determine which one receives clicks: relative Z-order can govern selection priority even when an object appears visually covered by another. The discussion emphasizes testing overlaps and explicitly setting the property when interactive controls share chart space.
The article applies this behavior to an indicator that displays an open position's entry, stop-loss, and take-profit levels. When levels overlap, selection priority can affect which line a trader can move or delete, and multiple positions introduce further collisions. The author describes adjustments intended to support both hedging and netting accounts and notes that position closure may only be detected after a chart timeframe change. This is an implementation discussion, not a trading strategy or performance study; the supplied excerpt gives no empirical trading results.
Key ideas
- Z-order can determine which overlapping chart object receives selection and click events.
- An object may appear behind another visually while still taking interaction priority.
- Overlapping entry, stop-loss, and take-profit lines can make editing or deletion ambiguous.
- Position-view indicators need to account for multiple open positions and both hedging and netting account models.
- The described indicator may not recognize that a position has closed until the chart timeframe changes.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.