NexusFi: Find Your Edge


Home Menu

 





Get all draw objects


Discussion in NinjaTrader

Updated
      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 gregid with 1 posts (0 thanks)
    1. trending_up 12,602 views
    2. thumb_up 4 thanks given
    3. group 8 followers
    1. forum 18 posts
    2. attach_file 1 attachments




 
Search this Thread

Get all draw objects

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


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
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #12 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425

@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 NexusFi Trade Journal Reply With Quote
  #13 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12


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
Elite Membership required to download: MembersOfChartObject.txt
Reply With Quote
  #14 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425

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 NexusFi Trade Journal Reply With Quote
  #15 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12


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)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #17 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12


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)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #19 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12


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;
                }
            }

Reply With Quote
Thanked by:




Last Updated on February 14, 2015


© 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