Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Accessing selected manually drawn chart drawing tag
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
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.
Someone sent me the solution to this a couple minutes ago, thought you might want to look at it.
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:
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
Thank you for posting this. Very helpful. Here's a bit I'm using to access a trendline object when clicked:
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