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 message in log

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

    Error message in log

    Platform NT 7.0.0.20

    I just noticed an error message that shows up in my log.

    "Failed to call method 'Initialize' for indicator 'PASwh2':
    Object reference not set to an instance of an object.

    Everything seems to work OK....I only noticed this by accident when I was
    nosing around in the log. The indicator in question (PASwh2) works fine.

    My question is.........
    What might be causing this error???
    Is the error something I should correct???

    Thanks..........

    #2
    photog53, this error could be caused by many, many different coding "errors". It usually occurs when you try to access some object without checking to see if it is null. If you post the code we can help narrow it down.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply.....

      I'll attach the code....

      (This indicator is based on the standard Ninja ZigZag....I added code to it)
      Attached Files

      Comment


        #4
        photog53, unfortunately nothing stands out in the Initialize() section that could be causing that error. You will have to wrap each section in try-catch blocks to see where exactly the error is coming from.
        Code:
        try
        {
            // do anything here, like access an array or something
        }
        catch (Exception ex)
        {
           Print("exception in init() for modified zig-zag at line [insert some line number reference here]: " + ex.ToString());
        }
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thanks......

          (I don't feel so dumb now...because I didn't see anything obvious either)....

          Comment


            #6
            I think I found the problem.....

            After some trial-and-error....I figured out the problem.

            I had the following code in .....

            protected override void Initialize()
            {
            ( other initialize code......)

            if (ChartControl.BackColor == Color.Black)
            targetBorder = Color.White;
            else
            targetBorder = Color.Black;

            I removed it and the log errors stopped.....

            It appears that I NT7 does not like using this code in initialize....

            Comment


              #7
              Glad you figured it out, this is correct - did you move it to OnStartUp() instead?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                I just commented it out for now....but OnStartUp is a good idea

                Thanks.....

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by PaulMohn, Today, 03:49 AM
                0 responses
                6 views
                0 likes
                Last Post PaulMohn  
                Started by inanazsocial, Today, 01:15 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by rocketman7, Today, 02:12 AM
                0 responses
                10 views
                0 likes
                Last Post rocketman7  
                Started by dustydbayer, Today, 01:59 AM
                0 responses
                4 views
                0 likes
                Last Post dustydbayer  
                Started by trilliantrader, 04-18-2024, 08:16 AM
                5 responses
                23 views
                0 likes
                Last Post trilliantrader  
                Working...
                X