Zorder for graphical objects

 

If I create overlapping graphical objects programatically, they are stacked in the order of creation. I want to have more control the same way as for click events with property OBJPROP_ZORDER. In the following example, the red rectangle (test2) is drawn on top of the white rectangle (test1) because it was created after that object (test1).

Is there a way to keep the red rectangle (test2) below the white rectangle (test1)?

ObjectCreate    (id, "test1", OBJ_RECTANGLE_LABEL, 0 ,0 ,0);
ObjectSetInteger(id, "test1", OBJPROP_XDISTANCE, 21);
ObjectSetInteger(id, "test1", OBJPROP_YDISTANCE, 22);
ObjectSetInteger(id, "test1", OBJPROP_XSIZE, 20);
ObjectSetInteger(id, "test1", OBJPROP_YSIZE, 20);
ObjectSetInteger(id, "test1", OBJPROP_BORDER_TYPE, BORDER_FLAT);
ObjectSetInteger(id, "test1", OBJPROP_COLOR, clrWhite);
ObjectSetInteger(id, "test1", OBJPROP_BGCOLOR, clrWhite);

ObjectCreate    (id, "test2", OBJ_RECTANGLE_LABEL, 0 ,0 ,0);
ObjectSetInteger(id, "test2", OBJPROP_XDISTANCE, 28);
ObjectSetInteger(id, "test2", OBJPROP_YDISTANCE, 29);
ObjectSetInteger(id, "test2", OBJPROP_XSIZE, 20);
ObjectSetInteger(id, "test2", OBJPROP_YSIZE, 20);
ObjectSetInteger(id, "test2", OBJPROP_BORDER_TYPE, BORDER_FLAT);
ObjectSetInteger(id, "test2", OBJPROP_COLOR, clrRed);
ObjectSetInteger(id, "test2", OBJPROP_BGCOLOR, clrRed);
 
leira:

If I create overlapping graphical objects programatically, they are stacked in the order of creation. I want to have more control the same way as for click events with property OBJPROP_ZORDER. In the following example, the red rectangle (test2) is drawn on top of the white rectangle (test1) because it was created after that object (test1).

Is there a way to keep the red rectangle (test2) below the white rectangle (test1)?

Why not create it before ? Or

   ObjectSetInteger(id,"test2",OBJPROP_BACK,true); 
 
angevoyageur:

Why not create it before ?

It is because these objects are created while new price bars develope.

Somehow I missed property OBJPROP_BACK. But that is something I can work with.
Thanks for this hint!