Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing certain objects behind bars and others in front

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Drawing certain objects behind bars and others in front

    I am looking for a way to draw some of my indicator's objects behind (the ones which cover large areas, for example...), while others need to be drawn in the front.

    I notice that zOrder is designed only to be set (SetZOrder()) in OnStateChange, and can't really be changed for one object and then restored.

    Any suggested solution?

    #2
    Hello Shai Samuel,

    Thanks for your post.

    SetZOrder is recommended to use for adjusting the ZOrder for the indicator. Setting a drawing objects ZOrder property directly will overwrite the assigned ZOrder which is relative to the indicator. We don't necessarily support changing the ZOrder of objects directly, but you may wish to experiment doing so to accomplish your goal. Here is an example for setting a drawing object's ZOrder property:

    Code:
    private HorizontalLine myLine;
    private HorizontalLine myLine2;
    
    protected override void OnBarUpdate()
    {
        myLine = Draw.HorizontalLine(this, "tag1", Close[0], Brushes.Red);
        myLine2 = Draw.HorizontalLine(this, "tag2", Open[0], Brushes.Green);
        myLine.ZOrder = 20002;
        myLine2.ZOrder = int.MaxValue;
    }
    If you are taking this approach, I would suggest adding code that fetches the ZOrder when the object is drawn, and then adjusts it relative to the index that was assigned when it was drawn. This way you could adjust the ZOrder and it will not interfere with other indicators/drawing objects that get added.

    The ZOrder documentation page describes the relative ZOrder that objects are given and could give further insight to how you would want to set those indexes.

    ZOrder - https://ninjatrader.com/support/help...art_zorder.htm

    While this approach is unsupported, please let me know if this does or does not help resolve the matter.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    44 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    54 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    34 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    94 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    56 views
    0 likes
    Last Post PaulMohn  
    Working...
    X