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 Balage0922, Today, 07:38 AM
    0 responses
    1 view
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    19 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Working...
    X