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 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Mindset with 1 posts (0 thanks)
    1. trending_up 5,854 views
    2. thumb_up 4 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
 

Convert mouse x/y location to Time & Price

 
 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

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
Strategy stop orders partially filled
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
22 thanks
What is Markets Chat (markets.chat) real-time trading ro …
19 thanks
ApexTraderFunding.com experience and review
15 thanks
GFIs1 1 DAX trade per day journal
15 thanks
EG Indicators
11 thanks
 
 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
Thanked by:
 
 
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.

 
 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
 
 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??

 
 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.

 
 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
 
 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.


 



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