Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    36 views
    0 likes
    Last Post love2code2trade  
    Started by alifarahani, Today, 09:40 AM
    2 responses
    13 views
    0 likes
    Last Post alifarahani  
    Started by junkone, Today, 11:37 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by pickmyonlineclass, Today, 12:23 PM
    0 responses
    1 view
    0 likes
    Last Post pickmyonlineclass  
    Started by frankthearm, Yesterday, 09:08 AM
    12 responses
    44 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X