Z-Order with chart-objects. What works?

 

Hi, 

since I dont know when, I try to figure out how the z-order works with MQL chart objects and my conclusion is so far that nothing works, no matter which value I give a chart object and its always random. For example:


The picture shows a pattern and vertical lines, this comes from a BitmapLabel object, which covers the whole chart and which I use for custom drawing by the EA, canvas based. The horizontal line in red, is a regular line, manually created, same with the blue line. The price-level texts are done by the canvas (bitmap-label). The canvas is created first when EA loads. 

This happens in 1 of 1000 cases, that the canvas is above one or more lines, usually its not. Hows that even possible that one line is overlapped and the other is not? I tried any kind of value for Z-Order for the bitmap-label and none has any effect. 

Has anyone an idea?

 

As per the documentation, the Z-order property has nothing to do with visual layering and only to do with mouse click priority ...

OBJPROP_ZORDER

Priority of a graphical object for receiving events of clicking on a chart (CHARTEVENT_CLICK). The default zero value is set when creating an object; the priority can be increased if necessary. When objects are placed one atop another, only one of them with the highest priority will receive the CHARTEVENT_CLICK event.

long

Documentation on MQL5: Types of Chart Events / Constants, Enumerations and Structures
Documentation on MQL5: Types of Chart Events / Constants, Enumerations and Structures
  • www.mql5.com
There are 11 types of events that can be processed using the predefined function OnChartEvent() . For custom events 65535 identifiers are provided...
 

The Z-Order determines which Object receives, the Click event. A simple experiment to better understand this: create 2 rectangles that overlap at the centre, set random z-order for each, and output the name of the object clicked from CHARTEVENT_OBJECT_CLICK.

If both objects have the same Z-order, then the Time of creation determines which object receives the click event.

In your creation/indicator, the objects displayed visually are in the order of creation: the Red line is behind because it was created before the Bitmap object; similarly, the Blue is above because it was created after the Bitmap object.