Establishing the Hierarchical Order of Chart Draws of Lines and Labels

Back to topics list  | 1 2 3 To post a new topic, please log in or register
avatar
17
traderathome 2014.03.05 21:21 #
 
angevoyageur:

Thank you.

Isn't exactly the usage of OBJPROP_ZORDER ?

Why placing objects on top of each other, seems weird to me.



My understanding is that OBJPROP_ZORDER has to do with actual clicking on the chart to obtain some result. That is not the subject. The subject is controlling the z-axis level at which objects are drawn, across multiple indicators regardless of the indicators position on chart list of indicators. Anyone with a mind's eye to chart esthetics understands how important this control is.
avatar
Moderator
3206
angevoyageur 2014.03.05 21:26 #
 
traderathome:

My understanding is that OBJPROP_ZORDER has to do with actual clicking on the chart to obtain some result. That is not the subject. The subject is controlling the z-axis level at which objects are drawn, across multiple indicators regardless of the indicators position on chart list of indicators. Anyone with a mind's eye to chart esthetics understands how important this control is.
Sorry, personally I use the charts to trade, not to draw.

avatar
98
JPS 2014.03.17 10:04 #
 

traderathome, I think I can help. Like you, I've been banging my head with this one too. Sometimes traders want info drawn on their chart - that is why there is the ability to create text and labels, otherwise what is the use, remove them from MT4 altogether if no one needs them, right? Having them alone is not enough. Like you mentioned - pleasing to the eye is important too. I completely understand you here!

We need to work around, because things work much differently now, even if makes absolutely no logical sense. I will address that one first.

First, realize that no matter how you name them alphabetically or what order you create them, anytime a user closes MT4 and restarts, the order of creation, etc won't matter because the objects will switch order on you!!! See ignored thread here that clearly points this out! https://forum.mql4.com/61480

Solution is to delete the objects using UninitializeReason(), then recreate them later. Thankfully REASON_CLOSE has been added !! This was not true in older builds. https://forum.mql4.com/58052

Now, I know what you are thinking (like myself) and that is "I am storing info on text objects, if I delete them I lose information".

So, this is what I am doing.

1. Create your objects in the order you wish them to appear.

2. OnDeint(), UninitializeReason() REASON_CLOSE, remove what you absolutely do not need to remain on chart, although keep everything that is storing info.

3. When client reopens MT4, pass the stored Object Description information to a string, delete the Object that was storing information, then redraw it again (in order it should appear) and pass your string value to the new recreated object that is taking the place of the one you deleted. Name can be the same as original. This can be achieved quickly on start up (or single tick). Trader won't notice.

I understand you are frustrated like I was, but hopefully this workaround helps you. Kind regards.





avatar
4
pt007 2015.10.14 05:14 #
 
SDC:

So the thread is about placing multiple objects in the same location and establishing which object will be the on top object when clicking on them, well why didnt you say that OP ? lol

I believe angevoyaguer is correct, OBJPROP_ZORDER allows to give one object priority over the others. When clicking on objects that are stacked/layered/on top of each other the one with the higher priority will respond.

I've just spent hours trying to use OBJPROP_ZORDER so the correct object can be clicked - without success. Changing the zorder makes no difference. Strangely when the correct object is clicked the Chart Event that is generated can be for an objects many pixels away on the y - axis.

Also create order of the object makes no difference to which object appears in the Chart Event click function.

avatar
Moderator
3412
GumRai 2015.10.14 05:28 #
 
pt007:

I've just spent hours trying to use OBJPROP_ZORDER so the correct object can be clicked - without success. Changing the zorder makes no difference. Strangely when the correct object is clicked the Chart Event that is generated can be for an objects many pixels away on the y - axis.

Also create order of the object makes no difference to which object appears in the Chart Event click function.

I have found that clicking on a label has no effect if the label is drawn on top of a rectangle label. The chart event will always be that the rectangle label has been clicked.

This means that you need to back the label with a smaller rectangle label or use an Edit object instead. 

avatar
4
pt007 2015.10.14 05:48 #
 

I've found 2 workarounds for ZORDER not working:

1. remove less important and conflicting objects!

2. when clicking a object the wrong object is often reported in the ChartEvent click function. However if the object is dragged (even for only a pixel) the correct object is reported in the ChartEvent click function.

Back to topics list   | 1 2 3  

To add comments, please log in or register