Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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 trilliantrader, 04-18-2024, 08:16 AM
                4 responses
                18 views
                0 likes
                Last Post trilliantrader  
                Started by mgco4you, Today, 09:46 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by wzgy0920, Today, 09:53 PM
                0 responses
                9 views
                0 likes
                Last Post wzgy0920  
                Started by Rapine Heihei, Today, 08:19 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by Rapine Heihei, Today, 08:25 PM
                0 responses
                10 views
                0 likes
                Last Post Rapine Heihei  
                Working...
                X