Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartObjects type checking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ChartObjects type checking

    Hey guys,

    I'm having trouble confirming (or getting) the type for IChartObjects on a chart. My objective is to use OnRender() to check for a type and if it is a horizontal line, then I want to write the value of that line. For example, if that line is drawn by using F6 at 1150 on a TF chart, then I want to write "1150.0" for reference on that chart, just over that horizontal line.

    I'm sure I can do that using RenderObject but I can't get to the point where I can even call RenderObject.

    Consider the code:
    Code:
    	foreach (Gui.NinjaScript.IChartObject c in myObjects)
    	{
                    if( c.Name ==  "Horizontal Line" ) 
    		{
                        NinjaTrader.NinjaScript.DrawingTools.HorizontalLine chl = c as NinjaTrader.NinjaScript.DrawingTools.HorizontalLine;
    		}
    	}
    My problem is chl ends up being null so I can't use anything for the c chart object that the visual Studio debugger has no problem seeing.

    And if I check like this, which I'd rather do than the above, I never get into the code where I can use the values for "c":

    Code:
    	foreach (Gui.NinjaScript.IChartObject c in myObjects)
    	{
                    if( c is HorizontalLine ) 
    		{
                        NinjaTrader.NinjaScript.DrawingTools.HorizontalLine chl = (c as NinjaTrader.NinjaScript.DrawingTools.HorizontalLine);
    		}
    	}
    I never get past "c is HorizontalLine" as though c isn't of type HorizontalLine. Well, yes it is of type HorizontalLine! I can clearly see that "c" is a HorizontalLine when I step through it in the debugger and I can see all its objects so there must be something I'm not doing correctly but I'm at a loss as to what.

    Can you help?

    #2
    Originally posted by traderpards View Post
    Can you help?
    Take a look at post #5 for an example of just what your looking for..




    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      Thanks Edge!

      I'll probably use what you suggest but I'd still like to know why what I'm doing doesn't work though... Because I got what I'm doing from Ninjatrader's support documentation and it should work, it seems to me.


      Would you happen to know why?

      Comment


        #4
        Apparently, this code does work but only if you just drew the line. The HorizontalLine object is null if the user drawn line already exists.

        I don't believe that should be... the code:

        Code:
        if( c is HorizontalLine )
        should return true if c is a HorizontalLine regardless of whether the user just drew it or if it already exists and the code:

        Code:
        NinjaTrader.NinjaScript.DrawingTools.HorizontalLine chl = (c as NinjaTrader.NinjaScript.DrawingTools.HorizontalLine);
        should return a valid object if that's what the object in the DrawObjects array actually is.

        Right??
        Last edited by traderpards; 11-16-2015, 01:48 PM.

        Comment


          #5
          Originally posted by traderpards View Post
          Right??
          Right.. If you read that thread in it's entirety, you'll notice there is currently a problem with finding those objects that were previously drawn before a re-compile and reload of ninjascript.. Towards the end of the thread Dave mentions this has now been fixed and will no longer be an issue in the next beta...


          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #6
            Ha!!! Thanks then Edge!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            19 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            6 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Working...
            X