No announcement yet.

Partner 728x90


How to move HorizontalLine with codes?

  • Filter
  • Time
  • Show
Clear All
new posts

    How to move HorizontalLine with codes?

    All questions refer to NT8 v8.0.5.2

    Q1) I can create a HL in codes:
    private HorizontalLine myHL;
    myHL = Draw.HorizontalLine(this, "HL88", true, Close[0]-10, Brushes.Green, DashStyleHelper.Solid, 2);

    How to then move the HL with codes to a different Y value, say, Close[0]-20?

    Q2) Codes with "myHL.IsLocked" compile ok but when I type "myHL." in NinjaScript Editor, the intellsense shows a dropdown list but without "IsLocked" in the list. Why is this so?

    I'm new to NinjaScript, & having a hard time getting around. Pls help, thanks.

    Hello Tiang,

    Thanks for opening the thread.

    You can update the position of a drawing object by making a new call to that drawing object. You will also want to pay attention to the tag of the drawing object. If you specify different coordinates and the same tag, the drawing object with that tag will get updated to those coordinates.

    Please see the excerpt from the help guide below:


    A user defined unique id used to reference the draw object.

    For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time.

    I have asked the development team why IsLocked() does not list in Intelliprompt. This method is valid to access within code, and there is no forced internal code that prevents this from listing. The development team's prognosis is that it is a limitation of the software used to build the NinjaScript Editor.

    If you would like, I could submit a ticket to track this limitation.

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service


      Thanks Jim for your help, & pls "submit ticket to track this limitation". Any effort to improve the Intelliprompt & Help documentation is appreciated. Allow me to share why this is important.

      After much digging around the NT Forum, I found a way to get the y-value of HL:
      yValue = myHL.Anchors.First().Price;
      which I won't find out from NT8 help documentation.
      There are many other Properties & Methods that Intelliprompt doesn't show. And when the NT8 help documentation doesn't help either, it makes learning/using Ninjascript so much more difficult. I look forward to NT8 improvements. Thanks.


        Hello Tiang,

        As the improvements to IntelliPrompt come from software not developed by our development team, this issue will be tracked by them internally.

        We can create a ticket on our end to track the interest in improving the help guide. Could you point out any particular sections that are unclear or can be improved? Please be as specific as possible in how we can best improve them.

        I look forward to being of further assistance.
        JimNinjaTrader Customer Service


          Hi Jim,
          If it's more difficult to improve the Intelliprompt due to it's under 3rd party's control, not NT's, then the effort could be better directed to the NT8 Help doc. The important point is that complete info on Ninjascript be available, at at least one place. So what is NT's guiding principle on providing this info...The specific is just 1 eg to understand the principle behind. For specific, let's continue to use the HorizontalLine (HL) as eg. It's easy to guess what a user of HL would like, eg: how to read HL y-value, say, after it's been moved manually; if it's moved manually, is there an event that the coder can hook to; etc. As I mentioned previously, after digging through many NT Forum threads, I found out I can get the y-value by : yValue = myHL.Anchors.First().Price;
          The NT8 Help doc shows:
          Represents an interface that exposes information regarding a Horizontal Line IDrawingTool.

          Methods and Properties
          An IDrawingTool's ChartAnchor representing the starting point of the drawing object
          An IDrawingTool's ChartAnchor representing the end point of the drawing object
          A Stroke object used to draw the object


          // Instantiate a HorizontalLine object
          HorizontalLine myLine = Draw.HorizontalLine(this, "tag1", 1000, Brushes.Black);

          // Set a new Stroke for the object
          myLine.Stroke = new Stroke(Brushes.Green, DashStyleHelper.Dash, 5);
          From the Help doc above, I won't guess I need myHL.Anchors.First().Price to get the y-value. Even if I search for Anchors.First().Price in NT8 Help, it says "no result found". It'ld be great if NT can provide the documentation similiar like what Microsoft did on the .NET Class Library help doc, which provide complete info on a class definition, which include all properties, methods, inheritance tree, code usage eg, etc. in one location.
          Under NT current situation, I've to trough the NT Forum threads to hopefully find the answer. Regarding NT Forum, it's unclear sometimes whether what I'm reading apply to NT7, NT8, or both. I'm not saying the Forum is bad; in fact it's good, otherwise I won't be able to get your help right now. I just wish I could get complete ninjascript info preferably in 1 place, then I don't have to post in Forum for at least the simple stuffs, which also take much of your time.

          Thanks for help, Jim.


            Hello Tiang,

            I have submitted a feature request to improve sections of the help guide. Namely to cover any members available including relevant C# methods and properties within NinjaScript items. I gave the example of Anchors to be listed with the members of a C# collection.

            This feature request is being tracked with the ticket ID SFT-2185. You can reference this ticket ID in the Release Notes for the version of NinjaTrader 8 in which the help guide improvements have been implemented.

            Release Notes can be viewed here:

            Thanks for providing input to improve NinjaTrader.
            JimNinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by thebionukerlife, Today, 11:41 PM
            0 responses
            1 view
            Last Post thebionukerlife  
            Started by thebionukerlife, Today, 11:40 PM
            0 responses
            1 view
            Last Post thebionukerlife  
            Started by KirkHammett, Today, 11:15 PM
            0 responses
            Last Post KirkHammett  
            Started by soon123, Today, 11:12 PM
            0 responses
            Last Post soon123
            by soon123
            Started by JustinCross, Today, 09:48 PM
            0 responses
            Last Post JustinCross