Get all draw objects - futures io
futures io futures trading



Get all draw objects


Discussion in NinjaTrader

Updated by AlBundy
      Top Posters
    1. looks_one AlBundy with 7 posts (2 thanks)
    2. looks_two ratfink with 6 posts (2 thanks)
    3. looks_3 Koepisch with 2 posts (0 thanks)
    4. looks_4 bukkan with 1 posts (0 thanks)
    1. trending_up 8,216 views
    2. thumb_up 4 thanks given
    3. group 9 followers
    1. forum 18 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

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

 
Thread Tools Search this Thread
 

Get all draw objects

  #11 (permalink)
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
 
AlBundy's Avatar
 
Posts: 25 since Jun 2013
Thanks: 10 given, 12 received


ratfink View Post
I assume there is a nested access route through the object list, but I haven't used it so may be wrong.

Unfortunately this is not possible/supported for this object. The member is apparently not public. I try to get all members with the BindingFlags functionality.

Reply With Quote
The following user says Thank You to AlBundy for this post:

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
442 thanks
VWAP for stock index futures trading?
48 thanks
Want your NinjaTrader indicator created, free?
46 thanks
Is Amp at risk of going under?
24 thanks
Risk of trading micro futures
19 thanks
 
  #12 (permalink)
Birmingham UK
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
 
ratfink's Avatar
 
Posts: 3,652 since Dec 2012
Thanks: 17,422 given, 8,386 received

@gregid spotted it (ChartObject not IChartObject), so use this

 
Code
	bool done = false;

         protected override void Initialize()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            Overlay				= false;
        }
		

	protected override void OnBarUpdate()
        {
			if (!done)
			{
				foreach (ChartObject co in ChartControl.ChartObjects)
				{
					Print("Y is " + co.Y.ToString("0.00000"));
				}
				
				done = true;
			}
        }

Travel Well
Visit my futures io Trade Journal Reply With Quote
 
  #13 (permalink)
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
 
AlBundy's Avatar
 
Posts: 25 since Jun 2013
Thanks: 10 given, 12 received

I think it is not in the ChartControl object


I attached a file with all members of ChartObject.

There is Y and startY but nothing which looks like endY. I guess NT is saving this additional information somewhere else...

Somebody an idea?

Attached Files
Register to download File Type: txt MembersOfChartObject.txt (6.1 KB, 24 views)

Last edited by AlBundy; February 14th, 2015 at 10:34 AM.
Reply With Quote
 
  #14 (permalink)
Birmingham UK
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
 
ratfink's Avatar
 
Posts: 3,652 since Dec 2012
Thanks: 17,422 given, 8,386 received

Looks like you have to use the DrawObjects list and then convert (e.g. to ILine, etc) from there.

 
Code
		foreach (IDrawObject draw in DrawObjects)
		{
			Print("draw obj " + draw.ToString());
		}
e.g. will give:

draw obj Name='Horizontal Line' StartY='10981.40'
draw obj Name='Line' Time='13/02/2015 20:01:00', StartBar='3300' StartY='10967.79' EndTime='13/02/2015 20:26:00' EndBar='3325' EndY='10973.97'

(There is code in the Ninja manual for checking tags, etc.)

Travel Well
Visit my futures io Trade Journal Reply With Quote
 
  #15 (permalink)
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
 
AlBundy's Avatar
 
Posts: 25 since Jun 2013
Thanks: 10 given, 12 received


ratfink View Post
Looks like you have to use the DrawObjects list and then convert (e.g. to ILine, etc) from there.

 
Code
		foreach (IDrawObject draw in DrawObjects)
		{
			Print("draw obj " + draw.ToString());
		}
e.g. will give:

draw obj Name='Horizontal Line' StartY='10981.40'
draw obj Name='Line' Time='13/02/2015 20:01:00', StartBar='3300' StartY='10967.79' EndTime='13/02/2015 20:26:00' EndBar='3325' EndY='10973.97'

(There is code in the Ninja manual for checking tags, etc.)


The issue is the .ToString() method returns only 2 digits after comma for StartY and EndY. You tested it probably with DAX Future. Try it with EURUSD and you will see the problem. When you draw a line from 1.1356 to 1.1390 then it returns always 1.14 and this is useless.

I wrote a small program which returns all field and property values from ChartObject and there is definitely no EndX - see the attachment from my previous post. I don't understand from where .ToString() gets EndX?!

Reply With Quote
 
  #16 (permalink)
Birmingham UK
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
 
ratfink's Avatar
 
Posts: 3,652 since Dec 2012
Thanks: 17,422 given, 8,386 received


AlBundy View Post
The issue is the .ToString() method returns only 2 digits after comma for StartY and EndY. You tested it probably with DAX Future. Try it with EURUSD and you will see the problem. When you draw a line from 1.1356 to 1.1390 then it returns always 1.14 and this is useless.

I wrote a small program which returns all field and property values from ChartObject and there is definitely no EndX - see the attachment from my previous post. I don't understand from where .ToString() gets EndX?!

Yes, that's why I gave you the earlier example showing the 'ToString("0.00000") to get 5 places.

And look in the Ninja manual to see them using ILine objects from the DrawObjects list.

Travel Well
Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #17 (permalink)
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
 
AlBundy's Avatar
 
Posts: 25 since Jun 2013
Thanks: 10 given, 12 received


gregid View Post
There is a Y object, try this:
 
Code
foreach (ChartObject co in ChartControl.ChartObjects)
{
    // do your stuff here
    Print(co.Y.ToString());
}

Yes, but a line has a StartY and EndY and here I get only the start Y value.

Reply With Quote
 
  #18 (permalink)
Birmingham UK
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
 
ratfink's Avatar
 
Posts: 3,652 since Dec 2012
Thanks: 17,422 given, 8,386 received


AlBundy View Post
Yes, but a line has a StartY and EndY and here I get only the start Y value.

Which is why you need the DrawObject list to get an object that you can treat as an ILine which does have startY and endY, and can match tags with the ChartObjects list if you want to.

[you showed greg's code again, not the two versions I gave you, there is information in both and you need to get more information from the manual]

Cheers

Travel Well
Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #19 (permalink)
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
 
AlBundy's Avatar
 
Posts: 25 since Jun 2013
Thanks: 10 given, 12 received


ratfink View Post
Yes, that's why I gave you the earlier example showing the 'ToString("0.00000") to get 5 places.

And look in the Ninja manual to see them using ILine objects from the DrawObjects list.

Ratfink, you are the best!

In the ILine object is StartY and EndY and the values are double --> the values are exact and with them I can re-draw the lines!

For me the case closed! Again thank you very much. I did not know about the ILine object!

UPDATE:
When you iterate through DrawObjects you have to check which type the object is and then cast it to the according object. Example:

 
Code
            foreach ( IDrawObject oItem in DrawObjects )
            {
                switch ( oItem.DrawType )
                {
                    case DrawType.Line:
                        ILine oLine = (ILine) oItem;
                        Print(string.Format("Found Line:{0:G} - StartY:{1:0.00000} - EndY:{2:0.00000}", oLine.Tag, oLine.StartY, oLine.EndY));
                        break;
                    case DrawType.Text:
                        IText oText = (IText) oItem;
                        Print(string.Format("Found Text:{0:G} - '{1:G}' - Y:{2:G}", oText.Tag, oText.Text, oText.Y));
                        break;
                }
            }


Last edited by AlBundy; February 14th, 2015 at 02:41 PM. Reason: Additional information for the programmer
Reply With Quote
The following user says Thank You to AlBundy for this post:



futures io Trading Community Platforms and Indicators NinjaTrader > Get all draw objects




Upcoming Webinars and Events
 

Bookmap

May 28
     



Copyright © 2020 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