Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set a HorizontalLine to global in indicator

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

    How to set a HorizontalLine to global in indicator

    I want to create a HorizontalLine that's global (shows on all charts) in my (pricepanel) indicator.
    The manual says you can use the Draw.HorizontalLine(this, "stoploss", orderSLprice, true, "templatename") construct, but I don't want to use a template.
    And in all other overloads there's no 'isGlobal' parameter.
    Can I set the isGlobal afterward?
    I don't see such a property, so this doesn't work:

    NinjaTrader.NinjaScript.DrawingTools.HorizontalLin e line = Draw.HorizontalLine(this, "stoploss", orderSLprice, Brushes.Red, DashStyleHelper.Solid, 3, true);
    line.IsGlobal = true;


    #2
    Hello wjadevries,

    Thanks for your post.

    You would need to create your line as global, then change the other characteristics.

    Example:

    HorizontalLine myHline = Draw.HorizontalLine(this, "myLine", Close[0], true, ""); // uses the default template
    myHline.Stroke = new Stroke(Brushes.Red, DashStyleHelper.Dash, 3); // change to what you want

    Reference: https://ninjatrader.com/support/help...zontalline.htm

    Comment


      #3
      Thanks, that works.

      Comment


        #4
        Additional question:
        I've set such a global Horizontal Line in my indicator with:
        line = Draw.HorizontalLine(this, "profittarget", tpprice, true, "");

        Now I want to find it in another second indicator and change the y (price) value.
        I have to find it instead of using the original line variable, since the first indicator created it and the second indicator needs to change it.

        To find it in the second indicator I concluded that I can't use:
        line = DrawObjects["profittarget"];
        but instead have to use:
        line = DrawObjects["@profittarget"];

        That's probably because it's global, but that's fine.
        However if I want the price of the found line changed by using:
        line.StartAnchor.Price = tpprice;
        nothing happens.

        And if I recreate the line (from within the second indicator) with the same construct as in the first indicator:
        line = Draw.HorizontalLine(this, "profittarget", tpprice, true, "");
        then I get two lines (the one created from the first indicator and from the second indicator).
        They both have the exact same name (@profittarget) when I inspect them with the "Drawing Objects..." panel.

        What's happening and how should I resolve this?

        Comment


          #5
          Hello wjadevries,

          Thanks for your reply.

          To detect and change a global line, you would need to loop through the draw object collections on the chart and change its characteristics as you wish. This is shown in the help guide on this page (3rd example): https://ninjatrader.com/support/help...rawobjects.htm

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          599 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          344 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          558 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          557 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X