Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please document when system objects become available

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

    Please document when system objects become available

    I just got a null reference by trying to use ChartControl from State.Configure. So I looked in the ChartControl documentation and can find nothing about when it is safe to use it. (This use is in the context of a chart window.)

    I can find out experimentally, of course, but please include that in the documentation. I did not look, but I doubt that ChartControl is the only object missing that piece of information in its manual page.

    #2
    Hello ETFVoyageur,

    Thank you for your post.

    From the Help Guide at the following link: http://ninjatrader.com/support/helpG...artcontrol.htm
    Note: The ChartControl object is ONLY guaranteed to be available when a NinjaScript type initiates from a Chart Window. There are situations where an indicator or strategy starts from another Windows (such as the Control Center's Strategies Grid, or from a Strategy Analyzer), where the ChartContol object is NOT accessible. Therefore, the ChartControl object should always be safely accessed (e.g., from within a try-catch, or conditionally using null reference checks)
    Use a null reference check to ensure the ChartControl is available.
    However, Configure is not likely to have ChartControl. It would be the State DataLoaded when it would be available, but still recommended to use a null reference check. Please refer to the State documentation at the following link: http://ninjatrader.com/support/helpG...n-us/state.htm

    A null reference check in OnStateChange:
    Code:
    			else if (State == State.DataLoaded)
    			{
    				if (ChartControl != null)
    				{
    					// do something
    				}
    			}
    I would say an understanding of states and the object you are calling would be needed no matter if the documentation is there or not. Documenting every object and when it is available will be submitted to the Product Management team.

    Comment


      #3
      I had read that. I was probably too focused on an indicator that is only useful for a chart, and was wondering at what point ChartControl would be guaranteed provided it is used on a chart.. As I said, I can experiment to find out.

      That does bring up something else I have been meaning to ask. This "indicator" is really only useful for charts. It provides some things that are useful only for charts, and it does not generate any values. Is there any way to ensure that it does not get added to anything other than a chart?

      Comment


        #4
        Originally posted by ETFVoyageur View Post
        I had read that. I was probably too focused on an indicator that is only useful for a chart, and was wondering at what point ChartControl would be guaranteed provided it is used on a chart.. As I said, I can experiment to find out.

        That does bring up something else I have been meaning to ask. This "indicator" is really only useful for charts. It provides some things that are useful only for charts, and it does not generate any values. Is there any way to ensure that it does not get added to anything other than a chart?
        Code:
        IsChartOnly = true; //still undocumented!
        Does that handle it?

        NT Support: Can we get it documented, please?

        Comment


          #5
          Thank you, koganam.

          I have sent the note over to the Product Management team.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kempotrader, Today, 08:56 AM
          0 responses
          6 views
          0 likes
          Last Post kempotrader  
          Started by kempotrader, Today, 08:54 AM
          0 responses
          4 views
          0 likes
          Last Post kempotrader  
          Started by mmenigma, Today, 08:54 AM
          0 responses
          2 views
          0 likes
          Last Post mmenigma  
          Started by halgo_boulder, Today, 08:44 AM
          0 responses
          1 view
          0 likes
          Last Post halgo_boulder  
          Started by drewski1980, Today, 08:24 AM
          0 responses
          4 views
          0 likes
          Last Post drewski1980  
          Working...
          X