NexusFi: Find Your Edge


Home Menu

 





Convert mouse x/y location to Time & Price


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one YuvalW with 4 posts (4 thanks)
    2. looks_two saikodi with 3 posts (0 thanks)
    3. looks_3 Mindset with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,844 views
    2. thumb_up 4 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Convert mouse x/y location to Time & Price

  #1 (permalink)
 YuvalW 
USA
 
Experience: Beginner
Platform: NinjaTrader
Posts: 26 since Jul 2009
Thanks Given: 4
Thanks Received: 17

Hi all,

any idea of how can I convert mouse x/y location (on the chart panel) to Time/Price?

ChartControl has "GetTimeByX" method, this is internal method but I can try call it via reflection, but I don't see something for y/price conversion...

Thx for any help,

Yuval.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
 
  #3 (permalink)
 YuvalW 
USA
 
Experience: Beginner
Platform: NinjaTrader
Posts: 26 since Jul 2009
Thanks Given: 4
Thanks Received: 17


OK, got it:

 
Code
 
// Global vars.
private double priceMin;
private double priceMax;
private int boundsTop;
private int boundsHeight;
 
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) 
{
    priceMin = min;
    priceMax = max;
    boundsTop = bounds.Top;
    boundsHeight = bounds.Height;
 
    base.Plot(graphics, bounds, min, max);
}
 
private void chart_MouseClick(object sender, MouseEventArgs e)
{
    Panel chartPanel = sender as Panel;
    if (chartPanel == null)
        return;
 
    if (e.Clicks == 1)
    {
        double price = priceMax - (e.Y-boundsTop)*(priceMax-priceMin)/boundsHeight;
        Print(Instrument.MasterInstrument.Round2TickSize(price));
    }
}

Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

Have you tested this with multiple charts on same panel?
I think you will run into some issues with this code.

Reply With Quote
  #5 (permalink)
 YuvalW 
USA
 
Experience: Beginner
Platform: NinjaTrader
Posts: 26 since Jul 2009
Thanks Given: 4
Thanks Received: 17

No I have not.
Interesting... how the fib tools work on multiple charts? what values does it take? I'll check when I'll get back home..

Started this thread Reply With Quote
  #6 (permalink)
 saikodi 
Seattle WA/USA
 
Experience: Advanced
Platform: ThinkorSwim, NinjaTrader
Trading: ES, YM, CL
Posts: 27 since Oct 2012
Thanks Given: 3
Thanks Received: 13


YuvalW View Post
No I have not.
Interesting... how the fib tools work on multiple charts? what values does it take? I'll check when I'll get back home..

I know this is a very old post but I am looking for the same thing. On mouse click on a chart, I want to know the price where the click happened. I tried with the code posted here but that doesnt seem to work. Any ideas??

Reply With Quote
  #7 (permalink)
 saikodi 
Seattle WA/USA
 
Experience: Advanced
Platform: ThinkorSwim, NinjaTrader
Trading: ES, YM, CL
Posts: 27 since Oct 2012
Thanks Given: 3
Thanks Received: 13


saikodi View Post
I know this is a very old post but I am looking for the same thing. On mouse click on a chart, I want to know the price where the click happened. I tried with the code posted here but that doesnt seem to work. Any ideas??

Never mind. Figured it out.

Reply With Quote
  #8 (permalink)
 YuvalW 
USA
 
Experience: Beginner
Platform: NinjaTrader
Posts: 26 since Jul 2009
Thanks Given: 4
Thanks Received: 17


saikodi View Post
Never mind. Figured it out.

Hey,
Just saw it... Honestly I don't remember anything from this issue... Good you figured it... Lol

Started this thread Reply With Quote
  #9 (permalink)
 saikodi 
Seattle WA/USA
 
Experience: Advanced
Platform: ThinkorSwim, NinjaTrader
Trading: ES, YM, CL
Posts: 27 since Oct 2012
Thanks Given: 3
Thanks Received: 13


YuvalW View Post
Hey,
Just saw it... Honestly I don't remember anything from this issue... Good you figured it... Lol

Yeah it took a bit of searching around but finally got it. One great thing with forums is that you do get solutions and help if you need but there are many partial or incorrect postings that lead you the wrong way. And when something is incorrect / partial, generally there is no follow up to it. So you dont know why a particular approach does not work. :-)

Anyways, I am happy I get what I am looking for from this forum consistently.

Reply With Quote




Last Updated on October 26, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts