Accessing selected manually drawn chart drawing tag - NinjaTrader Programming | futures io social day trading
futures io futures trading


Accessing selected manually drawn chart drawing tag
Updated: Views / Replies:2,294 / 14
Created: by Xav1029 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Accessing selected manually drawn chart drawing tag

  #11 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

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
 
  #12 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


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

Reply With Quote
 
  #13 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received



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
The following user says Thank You to vvhg for this post:
 
  #14 (permalink)
Elite Member
Austin TX
 
Futures Experience: Intermediate
Platform: SaintGobain Crystal Ball
Favorite Futures: 6E
 
Posts: 80 since Oct 2010
Thanks: 102 given, 129 received


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
The following 2 users say Thank You to Jaba for this post:
 
  #15 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


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

Reply With Quote

Reply



futures io > > > > > Accessing selected manually drawn chart drawing tag

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ACSIL: How do I get the time value of a Vertical line that I have drawn on the chart yonatan Sierra Chart Programming 7 June 25th, 2012 08:20 AM
Accessing chart region 1 data from chart region 2 study? funk101 Sierra Chart Programming 4 June 17th, 2012 08:37 PM
Drawing trailing stop on chart protrader007 NinjaTrader Programming 6 July 22nd, 2011 01:47 AM
Accessing a chart from a strategy richtobey NinjaTrader Programming 3 December 31st, 2010 05:07 AM
How To Manually Remove A Text ALERT From A Chart jmca2000 NinjaTrader Programming 3 July 21st, 2010 01:46 AM


All times are GMT -4. The time now is 03:06 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-16 in 0.11 seconds with 19 queries on phoenix via your IP 54.163.209.109