How I get know if user clicked mouse button on the chart?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NT8 OnMouseDown
Collapse
X
-
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 FilesChelsea B.NinjaTrader Customer Service
-
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.Originally posted by NinjaTrader_ChelseaB View PostHello 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.
Comment
-
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.htmLast edited by NinjaTrader_ChelseaB; 08-31-2016, 08:54 AM.Chelsea B.NinjaTrader Customer Service
Comment
-
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.Originally posted by NinjaTrader_ChelseaB View PostHello 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.htmLast edited by Antny; 08-31-2016, 05:26 PM.
Comment
-
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
-
How can I access ChartScale from within a custom function?
It seems I can only access it from within OnRender()
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
331 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
550 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment