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

How to find out what the user has selected

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

    How to find out what the user has selected

    How to use NinjaScript to determine that a particular rectangle is selected on the graph?

    I go through all the elements on the graph and I want to know whether this element is selected or not.


    Code:
        foreach (ChartObject co in ChartControl.ChartObjects) // We go through all the elements on the graph
        {
           if (co is ChartRectangle) // If this is a rectangle then we work further
           {
              if( ??? ) // Here you need to determine that this particular rectangle is allocated by the user
              {             // how to do it?
                oneRect = (co as ChartRectangle);   // One specific rectangle with a graph
                oneRect.AreaColor = Color.Green;  // Give it another color
              }
           }
        }
    Last edited by KeenEdge; 05-08-2017, 09:00 AM.

    #2
    Thank you for your question KeenEdge. If we review the documentation for IDrawingTool,



    We see that we do not have a member that shows whether it is selected. We do, however, see that every drawing tool has a series of Anchors



    Rectangles have named anchors StartAnchor and EndAnchor for the 2 corners that define it which should be easier to use



    These will give you a Price and Time index. You can reference these during mouse events such as OnMouseDownPoint,



    And you can convert these to pixel coordinates with ChartControl.GetXByTime and ChartScale.GetYByValue




    The idea from here will be to set up a boolean value that starts out false, can only be changed to true when the mouse clicks on the rectangle, and is reset to false when the user clicks off the rectangle. Doing so is up to the programmer, but one final piece of information you will need is the rectangle's pixel width. This is not a property of the rectangle, but is something you specify when calling Draw.Rectangle,



    So you will want to keep a reference to this width handy to determine whether the user clicked on the pixel border of the rectangle, and not within the empty space inside the rectangle. Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      I need for NT7, You gave me for NT8.
      This method is very complicated. There are built-in tools how to identify the item that is highlighted?

      Comment


        #4
        I will leave this up in case a forums user would like to develop custom code to achieve this goal. NinjaTrader 7 is no longer under active development, and any feature request for a simple property which shows in NinjaScript whether a drawing object is selected will have to be made for NinjaTrader 8. If you would like a custom solution developed for NinjaTrader 7 and a forums user is unable to help, please let us know so we may put you in touch with a NinjaScript consultant.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JessicaP View Post
          I will leave this up in case a forums user would like to develop custom code to achieve this goal. NinjaTrader 7 is no longer under active development, and any feature request for a simple property which shows in NinjaScript whether a drawing object is selected will have to be made for NinjaTrader 8. If you would like a custom solution developed for NinjaTrader 7 and a forums user is unable to help, please let us know so we may put you in touch with a NinjaScript consultant.
          Contact the NinjaScript consultant and ask how the program determines which object the user has selected object.
          I think the code for the definition should be the same or similar for NT7 and NT8.

          Comment


            #6
            Hello KeenEdge,

            You can search the extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

            This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

            Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
            Ryan L.NinjaTrader Customer Service

            Comment


              #7
              If you select an object, and then right-click anywhere else on the graph, then call the properties. Then the ninja define the properties for the selected object. How does it determine that this object is selected? In which variable is this selected object stored or what property is it for the selected object?

              Comment


                #8
                There is no public documented property.

                I have submitted a feature request to the product management team for the following feature :

                This user would like to add a public read-only Selected property to IDrawObject which indicates whether a user has clicked on it
                I will follow up with more information as soon as it's available. If the feature requests already exists, a vote will be added to it.


                Please let us know if there are any other ways we can help.
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello KeenEdge,

                  This feature is being reviewed by the product management team and has been assigned the following unique tracking ID


                  SFT-2243



                  Please let us know if there is any other way we can help.
                  Jessica P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Mestor, 03-10-2023, 01:50 AM
                  16 responses
                  388 views
                  0 likes
                  Last Post z.franck  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  4 responses
                  31 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by yertle, Yesterday, 08:38 AM
                  7 responses
                  29 views
                  0 likes
                  Last Post yertle
                  by yertle
                   
                  Started by bmartz, 03-12-2024, 06:12 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post bmartz
                  by bmartz
                   
                  Started by funk10101, Today, 12:02 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post funk10101  
                  Working...
                  X