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.
    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


    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 Waxavi, Today, 02:10 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          13 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          5 responses
          23 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X