NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-03-2008, 04:56 AM   #1
cls71
Senior Member
 
Join Date: Jan 2008
Location: Madrid, Spain
Posts: 231
Thanks: 2
Thanked 0 times in 0 posts
Default MouseMove event

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;
}
cls71 is offline  
Reply With Quote
Old 06-03-2008, 05:03 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

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
NinjaTrader_Dierk is offline  
Reply With Quote
Old 12-28-2009, 04:03 AM   #3
traderT
Member
 
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
Default Any progress on this?

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.
Attached Images
File Type: jpg Example.JPG (76.8 KB, 90 views)
Attached Files
File Type: cs TCDrawLine.cs (8.3 KB, 27 views)
traderT is offline  
Reply With Quote
Old 12-28-2009, 04:44 AM   #4
bukkan
Senior Member
 
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
Default

Quote:
Originally Posted by traderT View Post
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.
havent look at the code, but basically you got to figure out the bar counts (of the two points). mouse position will only get you the pixel point. you have to calculate the bar count from those pixel points. once you figure out the bar count then its piece of cake.

http://www.ninjatrader-support2.com/...catid=3&id=245
bukkan is offline  
Reply With Quote
Old 12-28-2009, 06:07 AM   #5
traderT
Member
 
Join Date: Nov 2008
Location: London
Posts: 53
Thanks: 0
Thanked 0 times in 0 posts
Default ypos?

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.
traderT is offline  
Reply With Quote
Old 12-28-2009, 06:16 AM   #6
bukkan
Senior Member
 
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
Default

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.
bukkan is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 05:34 AM.