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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    42 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X