![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: Jan 2008
Location: Madrid, Spain
Posts: 231
Thanks: 2
Thanked 0 times in 0 posts
|
Greetings,
I am doing an indicator for displaying the mouse coordinates in MouseMove event. The indicator calls the method "chart_MouseMove" when the mouse is moved but the text isn't updated. Is there any way for calling to Plot method ? Now the indicator works fine only when clickmouse or Alt+Tab windows or key press. ( I know that this doubt is beyond the scope of what you provide support for but I would be very grateful if you could help me ). Thanks very much. protectedoverridevoid OnBarUpdate() { if ((ChartControl != null) && (!_initMouseEvents)) { this.ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); _initMouseEvents = true; } } publicoverridevoid Plot(Graphics graphics, Rectangle bounds, double min, double max) { _boundsChart = bounds; _minChartPrice = min; _maxChartPrice = max; graphics.DrawString( "Y: " + _mouseOffset, fontTexto, brushTexto, 10, 280 ); } privatevoid chart_MouseMove(object sender, MouseEventArgs e) { if (ChartControl != null) { double price1 = ConvertYtoPrice ( e.Y ); _mouseOffset = price1 ; } } privatedouble ConvertYtoPrice (int i) { int _tickLength=0; if (TickSize < 1) _tickLength = TickSize.ToString ().Length-2; double chartscale = Math.Abs (_maxChartPrice - _minChartPrice); double boundAreaScale = _boundsChart.Bottom - _boundsChart.Y ; double ratio = (double)(chartscale)/ boundAreaScale ; double chartPrice = Math.Round ( (_minChartPrice ) + ((_boundsChart.Bottom -i) * ratio), _tickLength); return chartPrice; } |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Sorry, but as you already figured this clearly is beyond the scope what we provide support for, since coding at that level easily could screw up NT if you don't know exactly what you are doing.
As last resort you could contact a certified NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
|
Hi cls71
Did you manage to make any progress with your code. I am also trying to capture the mouse/crosshair location and use this within an indicator. Basically my indicator is a drawing tool that can be used to measure the ticks between 2 points. The idea is to alt-click once at one point on the chart, then alt-click again on the 2nd point. A line should then appear between the two points as well as the distance between the two points. What I am missing is the X and Y coordinates of the two alt-mouse clicks. I have attached my code for you to have a look at and any suggestions/help would be much appreciated. The sample pic shows what I am trying to achieve. Currently my code has the X and Y coordinates fillled in, but I would like to use what you have done, if it works, and use chart clicked coordinates in my code. |
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
|
Quote:
http://www.ninjatrader-support2.com/...catid=3&id=245 |
|
|
|
|
|
|
#5 |
|
Member
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
|
Hi bukkan,
Thanks for the info, I see that converting the xpos to barcount is fairly straight forward, however I am a little stumped on how to do the ypos - how can I determine the ypos and then convert it to price? As this is not always from a high to a low, I need to calc and convert the ypos too. |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
|
the said indi does not calculates the price scale as it is redundant for its need.
anyway, the bars itself contains the price value. isnt it. like Close[barcount] will give you the closing price of that bar. now you got to calculate a range and then some more calculation beween the pixel pts (where the mouse was clicked) and you will find what you need. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| event-driven methods? | mktrend | General Programming | 8 | 04-29-2008 06:17 AM |
| Order Event Warning | Moda1 | Miscellaneous Support | 4 | 02-14-2008 09:44 AM |
| Live Events - Seen After the Event | jstockman | Miscellaneous Support | 3 | 09-26-2007 04:37 PM |
| Strategy Start/Stop Event | Json | Strategy Development | 1 | 05-01-2007 03:55 AM |
| Chaining strategy and event | afifio | ATM Strategies (Discretionary Trading) | 6 | 06-26-2005 01:52 PM |