Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mouse click dead end

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

    Mouse click dead end

    I have a couple of Xs I'm drawing on the screen. One represents a profit target and the other represents a stop loss. (30 ticks from the entry for both in this case.) I want to be able to click the X and cancel the stop loss or profit target. But before I can do that, I need to get the mouse click coordinates so I can perform a test to see if the user actually clicked in the square. The attachment seems to show the Xs drawn correctly because when I lay my crosshairs over the middle of either X, it looks like exactly 30 ticks from the entry, just like I told it to.

    In my
    Code:
    mouseDown( object sender, System.Windows.Input.MouseEventArgs e)
    handler, no matter how I get the mouse click coords, they are seemingly incorrect.

    To get the mouse-click coords, In one case I'm trying:
    Code:
     Point pA = e.GetPosition(this as IInputElement );
    The other case I'm trying:
    Code:
    Point p = mouse.chartControl.MouseDownPoint;
    Neither one is even close to the rectangle. I did find in the docs a call to ChartingExtensions.ConvertToHorizontal/VerticalPixels() and that changes the coords on the former, but still doesn't get me close to my rectangle coords. (It actually changes pA to P). And when I say, "not even close," it's pretty bad - off by like 400 pixels (I think they're pixels) for the X-coord and 50 or so for the Y.

    I'm obviously missing something. Can someone help me figure out what I seem to be missing?
    Attached Files

    #2
    How did you draw these objects? Your code or NT code?

    Is there any relation to F being enabled or not?

    Is it consistent? I'm sure you've looked at x/y starting points..

    Can you post some code that removes all your logic and draws an X somewhere on the chart in the same way?.


    I can't completely tell without testing whatever you are doing - but do you have any windows scaling involved? You might be related to my other issue. Set everything to 100% in Windows display to see if it works??

    Comment


      #3
      Hi traderpards,

      I have a script that you may find helpful. This indicator draws a dot anywhere you click on the chart panel that has the indicator on it.
      Attached Files
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Makes no sense

        Thank you Sledge and Chelsea for looking at this...

        I coded up a quick indicator that draws a rectangle in the center of the chart. I'm also drawing the coordinates of the rectangle in the upper left corner of the chart. All I did was get the center of the chart and then make the box around that 20 x 20. Then, in the mouse-click handler, after the user clicks anywhere in the chart, I'm posting a message that tells if the mouse clicked inside the rectangle or outside of it. (The user always clicks outside of it.)

        I said in my original post that the mouse click points were way off. This is much closer and there seems to be a logic issue.

        Shouldn't the top of the rectangle be greater than the bottom of the rectangle? Left is less than right so that makes sense. I bet if I switched bottom and top in my conditional, it would work. Why would I want to do that?

        I guess my new question is what do I not understand about these coordinate references where top seems to be bottom and bottom seems to be top?
        Attached Files

        Comment


          #5
          Hi traderpards,

          The top of the chart has a 0 for the y value. This will increase as you move down.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          666 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          377 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          110 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          580 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X