Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Prevent drawing object in NinjaScript from being selected on chart

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

    Prevent drawing object in NinjaScript from being selected on chart

    Hi,

    Is there any way to prevent a drawing object that was produced within a script from being selected on a chart?

    Thanks,
    gbrad

    #2
    Hello gbrad,

    Thanks for your post.

    Yes, you can set the property IgnoresUserInput true for each object.

    Example:

    Dot myDot = Draw.Dot(this, "myDot1", true, 0, High[0]+ 6 * TickSize, Brushes.Red);
    myDot.IgnoresUserInput = true;


    Reference: https://ninjatrader.com/support/help...rawingtool.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,

      That was just what I was looking for...works great.

      Thanks for you help.

      gbrad

      Comment


        #4
        Hi,

        I would also like to prevent lines (created from Draw.Line) from being selected. I was looking to use IgnoresUserInput for this but it is not available for line objects.

        Is there an alternative method to prevent lines from being selected?

        Thanks,
        gbrad

        Comment


          #5
          Originally posted by gbrad View Post
          I would also like to prevent lines (created from Draw.Line) from being selected. I was looking to use IgnoresUserInput for this but it is not available for line objects.
          Your statement is incorrect.

          Did you try something like this,
          Code:
          [FONT=Arial]Line myLine = Draw.Line(this, "myLine1", ...);
          myLine.IgnoresUserInput = true;[/FONT]
          I think you have misunderstood the Draw.Line and/or Line help pages.

          Draw.Line returns a reference to a Line Object.

          A Line object implements the IDrawingTool interface.

          (The words "implements the XYZ interface" are very C-Sharpy geek-like
          code words -- do you understand this very technical sentence?)

          The property IgnoresUserInput comes from the IDrawingTool interface.

          Ergo, IgnoresUserInput is available.

          Hint:
          Look carefully at the top of the Line webpage, see the link to IDrawingTool?
          Last edited by bltdavid; 11-06-2021, 08:08 PM. Reason: IDrawingTool is a C# interface, not a class

          Comment


            #6
            Hi bltdavid,

            Yes, I did exactly what you did, but didn't get the same result. But, the good news is that your post helped in getting this resolved.

            By forcing IgnoresUserInput and compiling, these error messages appeared:
            'Line' is an ambiguous reference between 'NinjaTrader.Gui.Line' and 'NinjaTrader.NinjaScript.DrawingTools.Line'
            Cannot implicitly convert type 'NinjaTrader.Gui.Line' to 'NinjaTrader.NinjaScript.DrawingTools.Line'
            'NinjaTrader.Gui.Line' does not contain a definition for 'IgnoresUserInput' and no extension method 'IgnoresUserInput' accepting a first argument of type 'NinjaTrader.Gui.Line' could be found (are you missing a using directive or an assembly reference?)


            This piece of code did not work and gave the error messages above:

            Line DL = Draw.Line(this, "RangeLine-Max", false, -StartPoint, RefPoint-RangeMax, -(Length+StartPoint), RefPoint-RangeMax, C2, D2, W2, true);
            // forced line below...there is no IgnoresUserInput that shows in drop down box (could not get screenshot since selection box closes when trying to capture image).
            DL.IgnoresUserInput = true;


            Qualifying 'Line' with NinjaTrader.NinjaScript.DrawingTools.Line' resolved the the reference; this code worked:

            NinjaTrader.NinjaScript.DrawingTools.Line DL = Draw.Line(this, "RangeLine-Max", false, -StartPoint, RefPoint-RangeMax, -(Length+StartPoint), RefPoint-RangeMax, C2, D2, W2, true);
            DL.IgnoresUserInput = true;


            By using NinjaTrader.NinjaScript.DrawingTools.Line instead of Line cleared up things.

            I just assumed that IgnoresUnserInput was not available for Line since it didn't appear in the drop down box when I was trying to select it. I didn't realize at the time that it may be referencing 'NinjaTrader.Gui.Line' instead of 'NinjaTrader.NinjaScript.DrawingTools'.

            Thanks for responding to this post. It helped a lot.

            Regards,
            gbrad



            Attached Files

            Comment


              #7
              Excellent.

              Glad to hear I was able to help!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by andrewtrades, Today, 04:57 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              6 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              7 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X