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

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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X