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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    599 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    344 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    558 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    557 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X