Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

capturing mouse events?

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

    capturing mouse events?

    Hello, is there a way to capture & respond to mouse clicks on charts? (Specifically chart draw objects)

    #2
    Hello chuckt101,

    NinjaScript doesn't offer support for this but since it's built with C# you have the capability. For reference you can check MSDN docs or maybe another community member can share their experience with it.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply.

      I wasn't sure whether the mouse events would be filtered by NT before being sent to Ninjascript but it sounds like they aren't?

      Comment


        #4
        There's no filtering done, but it's also not actively looking for mouse events by default. There's likely additional using statement you need to add to any script for the right namespace.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi chuckt101, you can easily capture mouse x/y coordinates by adding an event handler to your indicators underlying control.

          Add something like this to your OnStartUp():
          Code:
          ChartControl.MouseMove += mouseMoveHandler;
          And add the method in your indicator
          Code:
          private void mouseMoveHandler(object sender, MouseEventArgs e)
          {
              // do whatever with mouse coords contained in e here
              Print(String.Format("mouseMoveHandler X = {0} Y = {1}!", e.X, e.Y))
          }
          X and Y are just examples, you can do things with clicks, mouse-wheel, etc. Hope this helps

          edit: if you simply want to capture clicks, you'll want to use the MouseDown event versus MouseMove. You can find a breakdown of mouse events on MSDN here http://msdn.microsoft.com/en-us/libr...mousedown.aspx
          Last edited by Dexter; 02-28-2011, 04:47 PM.

          Comment


            #6
            Thanks Dexter, that did help

            Comment


              #7
              Did this code snippet actually work for you?

              Comment


                #8
                dDrawABC uses this feature

                Check out the dDrawABC indicator. It uses mouse clicks.

                Comment


                  #9
                  Thank you johne5. That revealed my mistake....needed MouseDown on the ChartPanel...makes sense (now!).

                  Comment

                  Latest Posts

                  Collapse

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