Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Non clickable drawing objects

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

    Non clickable drawing objects

    Hello. I am developing a flag that draws objects in OnbarUpdate following logic of the type indicated in the sample code. The point is that I can't find a way for those objects not to be selectable with the click or double-click cursor. As they are drawn, I find it uncomfortable because sometimes I select it by mistake or double click and the object's properties menu opens. Is it possible to make them unselectable? Thank you



    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Close[0] > Open[0])
    && (Close[1] > Open[1]))
    {
    Draw.Dot(this, @"Example " + Convert.ToString(CurrentBars[0]), false, 0, High[0], Brushes.CornflowerBlue);
    }

    }​

    #2
    Originally posted by StephenGlover
    Yes, it is possible to make the objects you draw in OnBarUpdate unselectable. One way to achieve this is by using the SetObjectSelection function with the false parameter. This function sets whether an object can be selected or not.

    Here's an example code snippet that demonstrates how to make an object unselectable:
    ​// Draw an object
    DrawLine("myObject", 0, 0, 1, 1);

    // Make the object unselectable
    SetObjectSelection("myObject", false);

    ​In this example, a line object is drawn using the DrawLine function with the name "myObject". The SetObjectSelection function is then used to set the selection property of the object to false, which makes it unselectable.

    You can use the same approach to make any other type of object unselectable, such as rectangles, circles, or text objects. Simply draw the object and then use SetObjectSelection to make it unselectable.

    I hope this helps! Let me know if you have any other questions.
    SetObjectSelection doesnt exist in the current context.
    any way to fix this error?
    Thanks!

    Comment


      #3
      Hello manueldecastro,

      Thanks for your post.

      SetObjectSelect() as mentioned by StephenGlover is not a supported NinjaScript method or property which is why this error occurs.

      Drawing tools used within a script may be locked using the IsLocked property in NinjaTrader 8. When true, this will lock the drawing tool in question in place on the chart. Here's a link to our help guide that goes over this:

      https://ninjatrader.com/support/help...8/islocked.htm

      An example of this could be found on this forum thread: https://forum.ninjatrader.com/forum/...86#post1101686

      Please let me know if I may assist further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Hello, I have IsLocked established, but that does not prevent you from being able to click on those objects, which is sometimes uncomfortable. Is there no way for these objects to be "transparent" at the click of the mouse? Thank you

        Comment


          #5
          Hello manueldecastro,

          Thanks for you note.

          You could lock drawing objects on the chart using IsLocked but there are no documented/supported methods or properties available that would allow you to prevent a drawing object from being selectable on the chart.

          This forum thread will be open for other community members to share their insights on possible unsupported code to accomplish this.

          Let me know if you have further questions on this.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Have a look at IgnoresUserInput

            Code:
            Dot dot = Draw.Dot(this, @"Example " + Convert.ToString(CurrentBars[0]), false, 0, High[0], Brushes.CornflowerBlue);
            dot.IgnoresUserInput=true;
            ​
            Last edited by Bidder; 04-13-2025, 09:29 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            589 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            342 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
            555 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X