Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error in ChartControl

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

    Error in ChartControl

    Hello,

    I am getting an "Object reference not set to an instance of an object" error from the following simple line of code:

    ChartControl.ChartStyle.Pen.Color = Color.LightGray;

    I cannot understand why this line would throw an error since it is the syntax recommended in the following NT guide:

    http://ninjatrader.com/support/helpG...er_11_2010.pdf

    Suggestions?

    Thank you.

    #2
    Hello ivb73077,

    Thanks for your post.

    Are you certain that the error refers to that specific line and of that specific file?

    I've tried the line and had no issues.

    Comment


      #3
      Yes. The line is wrapped inside a Try/Catch block and the exception occurred therein. To determine the exact source of the error, I debugged using Visual Studio and it was this line that caused the exception to be thrown.

      Comment


        #4
        Hello ivb73077,

        Thanks for your reply.

        Using the Ninjascript IDE I've had no issues with that line in an indicator or a strategy.

        If you like, feel free to send in your script and I can test on my end. You can send to PlatformSupport[at]Ninjatrader[dot]com with atten Paul and a link to this thread in the subject line.

        Comment


          #5
          Originally posted by ivb73077 View Post
          Hello,

          I am getting an "Object reference not set to an instance of an object" error from the following simple line of code:

          ChartControl.ChartStyle.Pen.Color = Color.LightGray;

          I cannot understand why this line would throw an error since it is the syntax recommended in the following NT guide:

          http://ninjatrader.com/support/helpG...er_11_2010.pdf

          Suggestions?

          Thank you.
          Are you using that line in a called Indicator? IOW, is that line coming from code in an entity that is directly applied to a chart, or from an object that is being called by another object?

          Comment


            #6
            Yes. I am calling it from within an indicator.

            Can you please explain the impact this would have, if any? Thank you.

            Comment


              #7
              Originally posted by ivb73077 View Post
              Yes. I am calling it from within an indicator.

              Can you please explain the impact this would have, if any? Thank you.
              If the indicator is not directly applied to a chart, ChartControl does not exist. Check for it and escape if necessary.

              ref: http://ninjatrader.com/support/forum...ad.php?t=76551
              Last edited by koganam; 09-09-2015, 09:32 AM.

              Comment


                #8
                The peculiar issue is that I have ~15 ChartControl settings being called. All of them work except the line

                ChartControl.ChartStyle.Pen.Color = Color.LightGray;

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                560 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                325 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X