NexusFi: Find Your Edge


Home Menu

 





How to capture a mouse click's location on chart in NT7.


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one forrestang with 2 posts (2 thanks)
    2. looks_two asfax with 1 posts (4 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 rleplae with 1 posts (1 thanks)
    1. trending_up 1,556 views
    2. thumb_up 7 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

How to capture a mouse click's location on chart in NT7.

  #1 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

Hello.

THis is likely something that not too many people have experience doing in NT.

But what I am looking to do, is have an indicator, that once ENABLED(via button somewhere in the chart), that will capture the x/y position upon a mouse-click.

I'd then translate that into price and time.

I am thinking the ENABLE button would have to disable the native chart controls so that the clicking can occur. As I will be doing some reporting both onto the chart and to the output window.

But the most important things that I don't know how to do in NT7 are:
  • Create a button that will enable/disable the script while it is loaded onto a chart
  • Capture the X/Y position on mouse-click once that button is enabled

Just checking to see if anyone has done anything similar to this?

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


You may want to use something like this :

In the function that gets triggered when clicking the toolbar, you then can toggle a flag to stop your script.

 
Code
private ToolStripButton _myButton;

private void add_Button()
{
	try
	{
		ToolStrip toolStrip = ((Control)this.ChartControl).Controls["tsrTool"] as ToolStrip;
		if (toolStrip != null && toolStrip.Items.ContainsKey("btnMY") )
		{
			toolStrip.Items.RemoveByKey("btnMY");
		}

				
		if (toolStrip != null && !toolStrip.Items.ContainsKey("btnMY"))
		{					
			this._myButton = new ToolStripButton("butMY", (Image)null, new EventHandler(this.myButton_Clicked), "btnMY");
			this._myButton.CheckOnClick = true;
			toolStrip.Items.Add((ToolStripItem)this._myButton);
		}
		else
		{
			if (toolStrip.Items.ContainsKey("btnMY") )
			{
				//Print("Button btnMY exists");
			}
	        }
					
		if (this._myButton == null)
			return;
				
		this._myButton.Checked = ;
	}
	catch
	{
	}
}



private void remove_Button()
{
	ToolStrip toolStrip = ((Control)this.ChartControl).Controls["tsrTool"] as ToolStrip;
	if (toolStrip == null || !toolStrip.Items.ContainsKey("btnMY"))
		return;
	toolStrip.Items.RemoveByKey("btnMY");
			
}

private void myButton_Clicked (object sender, EventArgs e)
{
	// put your code here
}

protected override void OnStartUp()
{
	if (this.ChartControl == null )
	{
		return;
	}
	this.add_Button();
}

protected override void OnTermination()
{
	
	this.remove_Button();			
}

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 asfax 
Prague, Czech Republic
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: NQ
Posts: 57 since Sep 2009
Thanks Given: 34
Thanks Received: 79


forrestang View Post
Hello.

THis is likely something that not too many people have experience doing in NT.

But what I am looking to do, is have an indicator, that once ENABLED(via button somewhere in the chart), that will capture the x/y position upon a mouse-click.

I'd then translate that into price and time.

I am thinking the ENABLE button would have to disable the native chart controls so that the clicking can occur. As I will be doing some reporting both onto the chart and to the output window.

But the most important things that I don't know how to do in NT7 are:
  • Create a button that will enable/disable the script while it is loaded onto a chart
  • Capture the X/Y position on mouse-click once that button is enabled

Just checking to see if anyone has done anything similar to this?

Thanks

@forrestang
I wrote some code for you - add button to tool strip, if button is enabled and you clicked on chart, indicator prints info about clicked coordinates to output window. If you like print or draw some info into chart, input your code into Plot() function.

Attached Files
Elite Membership required to download: ButtonMouseCoordinates.zip
Reply With Quote
Thanked by:
  #5 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


asfax View Post
@forrestang
I wrote some code for you - add button to tool strip, if button is enabled and you clicked on chart, indicator prints info about clicked coordinates to output window. If you like print or draw some info into chart, input your code into Plot() function.

Wow sir!!!

That is EXACTLY what I needed. I should be able to do whatever I need to with that script.

These type of things I imagine not many of us have experience doing, so this helps out a ton.

Started this thread Reply With Quote
Thanked by:




Last Updated on April 21, 2017


© 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