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

get mouse click X and Y

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

    get mouse click X and Y

    Hello NT friends,

    Is there a way to get (X,Y) of middle mouse click? The (X,Y) should be relative to the chart rather than relative to the whole canvas.

    I see a code from a customized indicator (TraderRuler specific) that uses the following logic:
    cursor.clickPrice = ((double)(ChartControl.CanvasBottom) - (double)(yPix))/((double)(ChartControl.CanvasBottom)-(double)(ChartControl.CanvasTop));

    It is great if no pane indicators. However, if there is indicator at the bottom, then the above click price would be off as CanvasBottom coordinate is below indicator pane and the mouse click is relative to CanvasBottom.

    #2
    Originally posted by binwang2 View Post
    Hello NT friends,

    Is there a way to get (X,Y) of middle mouse click? The (X,Y) should be relative to the chart rather than relative to the whole canvas.

    I see a code from a customized indicator (TraderRuler specific) that uses the following logic:
    cursor.clickPrice = ((double)(ChartControl.CanvasBottom) - (double)(yPix))/((double)(ChartControl.CanvasBottom)-(double)(ChartControl.CanvasTop));

    It is great if no pane indicators. However, if there is indicator at the bottom, then the above click price would be off as CanvasBottom coordinate is below indicator pane and the mouse click is relative to CanvasBottom.
    Use Bounds instead of Canvas.

    Comment


      #3
      Originally posted by koganam View Post
      Use Bounds instead of Canvas.
      Thanks for the tip.

      I got the same result. Without indicator added, both Bounds and Canvas gave correct mouse click location. Once indicator panel is added, the Y will be off.

      By the way, in the original code, mouse click Y is obtained as (int)yPix = m.Y. m is the mouse click event.

      Any ideas?

      Comment


        #4
        Binwang2,

        Try going over this thread and particular to post #9
        http://www.ninjatrader.com/support/f...ad.php?t=23979
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        3 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        239 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X