Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Zorder Question

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

    Zorder Question

    Hi -

    I need to draw horizontal lines on an chart using an indicator. The line last drawn is the line that is displayed at the top. I need to control at what level the line draws so I thought I could the .ZOrder property of the HorizontalLine to ajdust the Zorder level.

    Find attached an indicator I built to test this. Also, below find the relevant segment of the code to review. I need the first line drawn to be on top and the last drawn line under the other two. I use the ZOrder property as follows:

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    Print("-------" + CurrentBar);
    {
    //This line should be on top
    NinjaTrader.NinjaScript.DrawingTools.HorizontalLin e hzlSwingL = Draw.HorizontalLine(this, "Line1", Close[0], true, "");
    hzlSwingL.Stroke = new Stroke(Brushes.Aqua , 10.0f);
    hzlSwingL.ZOrder = int.MaxValue;

    //This Line in the middle
    hzlSwingL = Draw.HorizontalLine(this, "Line2" , Close[0], true, "");
    hzlSwingL.Stroke = new Stroke(Brushes.Green , 20.0f );
    hzlSwingL.ZOrder = 29000 ;

    //This line should be below the first two
    hzlSwingL = Draw.HorizontalLine(this, "Line3" , Close[0], true, "");
    hzlSwingL.Stroke = new Stroke(Brushes.Red , 30.0f );
    hzlSwingL.ZOrder = 1 ;

    }
    foreach (IDrawingTool hLine in DrawObjects)
    {

    if(hLine is NinjaTrader.NinjaScript.DrawingTools.HorizontalLin e)
    {
    DrawingTools.HorizontalLine myLine = hLine as HorizontalLine;
    Print(">>>>HorizontalLine: " +myLine.Tag + " zOrder:" + myLine.ZOrder);
    }
    }

    Here is a sample from the Output window placed on a ES 12-19 5 minute chart:

    -------1128
    >>>>HorizontalLine: line1 zOrder:20273
    >>>>HorizontalLine: @Line2 zOrder:20274
    >>>>HorizontalLine: @Line3 zOrder:20275
    -------1129
    >>>>HorizontalLine: line1 zOrder:20273
    >>>>HorizontalLine: @Line2 zOrder:20274
    >>>>HorizontalLine: @Line3 zOrder:20275
    -------1130
    >>>>HorizontalLine: line1 zOrder:20273
    >>>>HorizontalLine: @Line2 zOrder:20274
    >>>>HorizontalLine: @Line3 zOrder:20275
    -------1131
    >>>>HorizontalLine: line1 zOrder:20273
    >>>>HorizontalLine: @Line2 zOrder:20274
    >>>>HorizontalLine: @Line3 zOrder:20275


    The lines are displayed in the order that they are drawn with the last line on top of the other two. The ZOrders are not being set.

    What am I doing incorrectly?

    How can I get the order of the lines to be drawn on the levels I need.

    Thank you

    ReorderZorder.zip
    Attached Files
    Last edited by kweiss; 10-01-2019, 07:27 PM.

    #2
    Hello,

    Unfortunately, the ZOrder cannot be directly set on a drawing object.

    The <IDrawingTool>.ZOrderType enum can be set but only has 3 settings: DrawingToolZOrder.Normal, DrawingToolZOrder.AlwaysDrawnFirst, and DrawingToolZOrder.AlwaysDrawnLast.


    In general, the ZOrder for drawing objects is controlled by changing the order in which the drawing methods are called.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    605 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    351 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    560 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    561 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X