NexusFi: Find Your Edge


Home Menu

 





Accessing selected manually drawn chart drawing tag


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Xav1029 with 8 posts (4 thanks)
    2. looks_two vvhg with 5 posts (3 thanks)
    3. looks_3 Jaba with 1 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,629 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 0 attachments




 
Search this Thread

Accessing selected manually drawn chart drawing tag

  #11 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824

I haven't tried his, but it might be that drawing objects are in fact controls. If they are you could do
 
Code
this.ChartControl.ActiveControl.Tag
to get the active one.
and then sth like
 
Code
DrawObjects["someTag"].DrawType
to get the type (line or ray or whatever).
If the above works this would come in handy as a possible event handler
 
Code
this.ChartControl.ActiveControl.GotFocus += new EventHandler(myCoolEventHandler);
All just an idea and untested, but should be easy to find out with a few print statements.

vvhg

Hic Rhodos, hic salta.
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #12 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377


vvhg View Post
I haven't tried his, but it might be that drawing objects are in fact controls. If they are you could do
 
Code
this.ChartControl.ActiveControl.Tag
to get the active one.
and then sth like
 
Code
DrawObjects["someTag"].DrawType
to get the type (line or ray or whatever).
If the above works this would come in handy as a possible event handler
 
Code
this.ChartControl.ActiveControl.GotFocus += new EventHandler(myCoolEventHandler);
All just an idea and untested, but should be easy to find out with a few print statements.

vvhg

This is all new to me, so could you explain where I would put the code? I think I can figure out the mouse event, but could you post code to print the tag of the selected control, and if no control is selected return? Just so I can figure it out

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #13 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824



Xav1029 View Post
This is all new to me, so could you explain where I would put the code? I think I can figure out the mouse event, but could you post code to print the tag of the selected control, and if no control is selected return? Just so I can figure it out

Was a false alarm, sorry. They are not controls it seems.
I had a look again, but I haven't found a way yet to check an IDrawObjects activation/focuse state.

vvhg

Hic Rhodos, hic salta.
Reply With Quote
Thanked by:
  #14 (permalink)
 Jaba 
Austin TX
 
Experience: Intermediate
Platform: SaintGobain Crystal Ball
Trading: 6E
Posts: 81 since Oct 2010
Thanks Given: 103
Thanks Received: 134


Xav1029 View Post
@vvhg

Someone sent me the solution to this a couple minutes ago, thought you might want to look at it.

 
Code
FieldInfo fi = typeof(ChartControl).GetField("selectedObject", BindingFlags.NonPublic | BindingFlags.Instance);
			if (fi != null)
			{
  				if (base.ChartControl != null)
    			        if (fi.GetValue(base.ChartControl) != null)
      			        Print(fi.GetValue(base.ChartControl).ToString());
			}
This will give you something like:
Name='Ray' Time='9/25/2012 4:32:28 PM', StartBar='2995' StartY='91.10' EndTime='9/25/2012 5:00:00 PM' EndBar='3034' EndY='90.99'

So now I just have to add it to a mouse event, and get to coding.

Thank you for posting this. Very helpful. Here's a bit I'm using to access a trendline object when clicked:

 
Code
using System.Reflection;

Type chartControlType = typeof(ChartControl);
FieldInfo fi = chartControlType.GetField("selectedObject", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null)
{
	if (base.ChartControl != null && fi.GetValue(base.ChartControl) != null)
	{
				object clickedObject = fi.GetValue(base.ChartControl);
				if(clickedObject.GetType() == typeof(ChartRay))
				{
					IRay trendLine = (IRay)clickedObject;
	       		Print("Selected a trendline: " +trendLine.Tag);
				}
	}
}
IRay = ChartRay
ILine = ChartLine, etc...


BTW, my first post here. Thank you for running this awesome place.
Jaba

Reply With Quote
Thanked by:
  #15 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377


Jaba View Post
Thank you for posting this. Very helpful. Here's a bit I'm using to access a trendline object when clicked:

 
Code
using System.Reflection;

Type chartControlType = typeof(ChartControl);
FieldInfo fi = chartControlType.GetField("selectedObject", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null)
{
	if (base.ChartControl != null && fi.GetValue(base.ChartControl) != null)
	{
				object clickedObject = fi.GetValue(base.ChartControl);
				if(clickedObject.GetType() == typeof(ChartRay))
				{
					IRay trendLine = (IRay)clickedObject;
	       		Print("Selected a trendline: " +trendLine.Tag);
				}
	}
}
IRay = ChartRay
ILine = ChartLine, etc...


BTW, my first post here. Thank you for running this awesome place.
Jaba

Thanks for posting that Jaba. I currently have all major code projects on hold while I concentrate on my trading, but this will be my next project. Next step would be adding entry conditions when price approaches the selected TL or S/R Line if you want to keep it going

Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on October 7, 2012


© 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