Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsLocked not working for Line object

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

    IsLocked not working for Line object

    Hello NT8 Team,

    When I create a Line object in code then set the line's .IsLocked property to false, the line still cannot be moved manually on the chart. Manually viewing the code-generated line's properties, I can see that the "IsLocked" box is checked. Manually unchecking the property will allow the line to be moved.

    What is the proper way to set IsLocked to false in code so that a program-created Line (or any other drawing object) can be manipulated by the user?

    Example code:
    Code:
    NinjaTrader.NinjaScript.DrawingTools.Line myLine = null;
    
    myLine = Draw.Line( this, "Line1", 4, 2350.00, 0, 2350.00, Brushes.Blue, DashStyleHelper.Solid, 3 );      // Horizontal line starting 4 bars ago
    myLine.IsLocked = false;         // This has no efffect. Line still locked on chart.
    Thank you.

    #2
    Hello D Trader,

    I am not able to reproduce this behavior.

    Below is a link to a short video demonstrating and attached is the test script.
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    What version of NinjaTrader are you using (Help -> About... e.g. 8.X.X.X)
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your timely reply, Chelesa.

      I am using NT 8.0.6.1 64-bit (Multi-Broker).

      I think I discovered the issue -- in code I re-use the same line (object) more than once by calling Draw.Line() with the same tag. It appears that even though .IsLocked was set to false when the line was first created by Draw.Line(), .IsLocked must also be set to false every time Draw.Line() is called with the same tag.

      To duplicate this behavior, just add a second call to Draw.Line() to your sample code, but don't set .IsLocked to false again.The line will be locked.

      I did not expect properties that were not explicitly specified in the call to Draw.Line() to be modified when the same object was re-used. Should this behavior occur? What about other properties I may assign directly to the line object? Will they also be reset by a subsequent call to Draw.Line()?

      Thanks again.

      Comment


        #4
        Hello D Trader,

        The variable holds the object. Each time Draw.Line() is called a new object is returned.

        (If the tag name is re-used, the old object will be removed from the chart before the new object is drawn and returned)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          If it is true that each call to Draw.Line() with the same Tag actually creates a new object, then may I suggest the NT support team update the online reference manual. According to the reference, referring to the Draw.Line() Tag parameter:

          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.
          However, my testing and your reply confirms that this is not true. What actually happens is that Draw.Line() is first calling RemoveDrawObject(), then creating an entirely new line to which it assigns the same Tag.

          This addresses the issue. Thank you for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          110 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          59 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          37 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          41 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          78 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X