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

NT8 OnMouseDown

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

    NT8 OnMouseDown

    Hello

    How I get know if user clicked mouse button on the chart?

    #2
    Hello ren37,

    Below I am providing a link to the NinjaTrader 8 Beta section of the forums (for future reference).
    http://ninjatrader.com/support/forum...splay.php?f=59

    To find if a user has clicked with the mouse, an event handler (method) will need to be added to the mouse down event.

    Attached is an example that demonstrates.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello ren37,

      Below I am providing a link to the NinjaTrader 8 Beta section of the forums (for future reference).


      To find if a user has clicked with the mouse, an event handler (method) will need to be added to the mouse down event.

      Attached is an example that demonstrates.
      I greatly appreciate the example indicator. But, after having experimented with it, I see it does not create objects relevant to the chart...but instead just creates objects on the chart. There is a simple way to make this indicator example immensely more useful. How do we convert a Point to a ChartAnchor? If this indicator demonstrated that, we could use the example to create, and modify objects on the chart, which are linked to the time and price.

      Comment


        #4
        Hello Antny,

        Are you trying to create a drawing tool?

        With the example I have provided, the y value comes from the mouse click, and is used to draw the dot as a rendered sharpdx object (not a drawing tool) from the indicator. This is not a drawing object script.

        To convert a y value to a price use:
        <theChartsScale>.GetValueByY();


        There is no documented code that provides a way to create anchors in an indicator. The anchors are created automatically by the drawing tool script that is being called from the indicator (like Draw.Dot()).

        Anchors from a drawing object would come from a drawing object script (for example when you clicking a drawing object from the drawing object menu on the chart toolbar) using the CreateAnchor() method from within the DrawingTool namespace.
        http://ninjatrader.com/support/helpG...eateanchor.htm
        Last edited by NinjaTrader_ChelseaB; 08-31-2016, 08:54 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Antny,

          Are you trying to create a drawing tool?

          With the example I have provided, the y value comes from the mouse click, and is used to draw the dot as a rendered sharpdx object (not a drawing tool) from the indicator. This is not a drawing object script.

          To convert a y value to a price use:
          <theChartsScale>.GetValueByY();


          There is no documented code that provides a way to create anchors in an indicator. The anchors are created automatically by the drawing tool script that is being called from the indicator (like Draw.Dot()).

          Anchors from a drawing object would come from a drawing object script (for example when you clicking a drawing object from the drawing object menu on the chart toolbar) using the CreateAnchor() method from within the DrawingTool namespace.
          http://ninjatrader.com/support/helpG...eateanchor.htm
          That is the basic idea. The problem with the CreateAnchor() info is, as far as i can tell, it requires all three bits of information (mouse-click point, time, and price) That makes it useless to me. I can get the mouse click point, but the time and price? There is no method (to my knowledge) that gives the time and price where the mouse cursor is. All I need to be able to do is recreate the actions of the line drawing tool... I click my custom indicator button, click on the chart to lock in my first anchor, and the second anchor tracks the location of the mouse until I click again, locking in the second anchor. The tool I am making is much more complex than any of the drawing tools. But, I can make it happen if I can just figure out how to do this.
          Last edited by Antny; 08-31-2016, 05:26 PM.

          Comment


            #6
            Hello Antny,

            There are methods that can give you the time and price of where you mouse have clicked. One of these I have mentioned in my previous post.

            The mouse click returns x and y values.

            To convert a y value to a price use:
            <theChartsScale>.GetValueByY();


            To convert an x value to a time use:
            <theChartsControl>.GetSlotIndexByX();
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              How can I access ChartScale from within a custom function?
              It seems I can only access it from within OnRender()

              Comment


                #8
                Hello trader3419,

                The ChartScale is provided by OnRender. After it is available you could save this to a handle (variable) and use this how you would like.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks Chelsea!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by fx.practic, 10-15-2013, 12:53 AM
                  5 responses
                  5,403 views
                  0 likes
                  Last Post Bidder
                  by Bidder
                   
                  Started by Shai Samuel, 07-02-2022, 02:46 PM
                  4 responses
                  94 views
                  0 likes
                  Last Post Bidder
                  by Bidder
                   
                  Started by DJ888, Yesterday, 10:57 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by MacDad, 02-25-2024, 11:48 PM
                  7 responses
                  158 views
                  0 likes
                  Last Post loganjarosz123  
                  Started by Belfortbucks, Yesterday, 09:29 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post Belfortbucks  
                  Working...
                  X