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

OnStartUp

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

    OnStartUp

    Hi,

    Are there any conditions under which OnStartUp would not be called, especially in Replay Mode?

    I have some code to initialize some List<> variables and started getting Object reference not set... I am doing the new List... in OnStartUp so I put a print statement to see where things were going wrong.

    The Print statement isn't getting executed either. Maybe I have this wrong but if I hit F5 to refresh the chart, I thought I would reload the indicator and should therefore go through Initialize and OnStartUp again.

    When using Lists is there anything I should be putting in Dispose() that could cause this (I have nothing in Dispose relating to these Lists)?

    Any thoughts?

    Best Regards,
    Scott
    Last edited by ScottB; 03-20-2011, 11:38 AM.

    #2
    I just stopped and restarted NinjaTrader. Because this indicator was on an open chart, it loaded when NinjaTrader did. Everything works fine; all the print statements and the code itself.

    When I then connect to Market Replay, I immediately get the error. It appears as though when you connect to Market Replay, only OnBarUpdate but not OnStartUp is called; is that correct?

    Comment


      #3
      I stopped and restarted NinjaTrader again and now it works with no other changes. Anyone who says gremlins are not real must not be a programmer.

      Comment


        #4
        Hello,

        Thanks for the forum post.

        Glad to hear its now working. If you return to having issues please let me know. Most likely this was all caused from that Object not set error which would cause these type of issues. We may still have a bug somewhere so if you run into it again please let me know and we will look into the object reference error.


        I look forward to assisting you further.

        Comment


          #5
          Brett,

          Thanks for getting back to me. You guys have the best support of any product I use (trading or otherwise).

          Comment


            #6
            Just ran into this bug

            I just ran into this bug as well - the OnStartUp for an indicator was never called. First time I've run into it in a long time without problems, so it appears to be a rare circumstance... I haven't been able to faithfully reproduce it yet.

            Some details when it occurred:

            - indicator was added to the strategy in Initialize()
            - indicator's initialize was called
            - was using MarketReplay with the Replay101 account
            - strategy's OnStartUp routine is called, but not the indicator's.
            - no exceptions were thrown
            Jeremytang
            NinjaTrader Ecosystem Vendor - Shark Indicators

            Comment


              #7
              Thanks for the input and observation here Jeremy, we will keep an eye out for this issue in our routine testings, when you see it again and have another detail that might help circling the issue in better, please don't hesitate to post it here.

              Thanks,
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Indicator.OnStartUp() not called when used in Strategy

                I read this thread with interest, as OnStartUp() is not called in my Indicator when I successfully create an instance of the Indicator in my Strategy. The Indicator works fine on it's own, just not when used from a Strategy.

                From the Strategy, I can see Indicator.Initialize() is called several times as usual. When I 'enable' the Strategy, I expect Indicator.OnStartUp() to be called. Nothing. No Print() statements. Visual Studio breakpoint not reached in the OnStartUp() method.

                I've been using Market Replay. When I click the Enable checkbox on the Strategy, it does not set to 'enable'. Sometimes, when I restart NT, I can get 'enable' to stay checked but Indicator.OnStartUp() still does not get called.

                For previous posts, has there been a solution to the issue in this tread? What might be the issue? Any suggestions? Thanks.

                Comment


                  #9
                  Buckstar, no further update I could unfortunately give since we're still after a reproducible scenario for this issue. Does that happen consistently for your setup and indicator / strategy combination? Would you mind then if we gave that a run here on our end to further check into? How much historical data do you load your MR chart usually with?
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    FYI -- This is still happening -- twice in the last 20 hours on one of my trader's systems.

                    I don't know know how to reproduce it unless you're willing to give me a copy of NinjaTrader sources. Then I guarantee you I would find it.

                    Yes, I know you're not going to do that.

                    So instead it's up to someone at NinjaTrader to do a code-review, and find out what conditions would cause OnStartUp to NOT be called immediately before the first call to OnBarUpdate.

                    Please let us know what these conditions are.

                    Comment


                      #11
                      While you are waiting.

                      Originally posted by KBJ View Post
                      FYI -- This is still happening -- twice in the last 20 hours on one of my trader's systems.

                      I don't know know how to reproduce it unless you're willing to give me a copy of NinjaTrader sources. Then I guarantee you I would find it.

                      Yes, I know you're not going to do that.

                      So instead it's up to someone at NinjaTrader to do a code-review, and find out what conditions would cause OnStartUp to NOT be called immediately before the first call to OnBarUpdate.

                      Please let us know what these conditions are.
                      I have run into this kind of thing quite a few times, but as, in my particular case, my code in every instance involved objects/methods from partial classes, I eventually decided that tracking the thing down without access to source code was a non-sequitur, so I took the other tack of using the good old fallback from NT6.5: instead of using OnStartUp() when this thing reared its head, I just processed it in OnBarUpdate() instead.
                      Code:
                      if (CurrentBar == 0)
                      {
                      //do all that misbehaving stuff here
                      }
                      Just my $0.02. I would think that it will be a long wait before NT Development can produce the problem with consistency, if at all. After all, not many users are reporting seeing it, which points to a niggling issue that is going to be hard to track down, no matter how competent the programmers.
                      Last edited by koganam; 04-13-2014, 09:45 AM.

                      Comment


                        #12
                        Originally posted by Buckstar View Post
                        I read this thread with interest, as OnStartUp() is not called in my Indicator when I successfully create an instance of the Indicator in my Strategy. The Indicator works fine on it's own, just not when used from a Strategy.

                        From the Strategy, I can see Indicator.Initialize() is called several times as usual. When I 'enable' the Strategy, I expect Indicator.OnStartUp() to be called. Nothing. No Print() statements. Visual Studio breakpoint not reached in the OnStartUp() method.

                        I've been using Market Replay. When I click the Enable checkbox on the Strategy, it does not set to 'enable'. Sometimes, when I restart NT, I can get 'enable' to stay checked but Indicator.OnStartUp() still does not get called.

                        For previous posts, has there been a solution to the issue in this tread? What might be the issue? Any suggestions? Thanks.
                        If this is the case, can you call the indicator's OnStartUp from the strategy?

                        Maybe make OnStartUp2 public to call this.OnStartUp??

                        Comment


                          #13
                          koganam & sledge: Thank you for your comments & suggestions (however I'd prefer to move to NT8 rather than porting my code back to NT6.5 -- and yes, I did use a "first-time flag" for doing initializations in OnBarUpdate instead of in OnStartup back when I was using NT6.5).

                          More info for NinjaTrader support & developers: Although I have seen this problem in strategies as well as in indicators, these last two instances of this OnStartUp error were found in two separate indicators on the same chart (so we observed two different error messages from two different indicators at the same time when the affected chart was refreshed.)

                          The problem in both cases (today and yesterday) went away after NinjaTrader was restarted. In both indicators the final initialization of a dataseries (e.g., "d_series = new DataSeries( this, MaximumBarsLookBack.Infinite );") did not complete, causing "d_series" to be null in OnBarUpdate which precipiated the error of "Object reference not set to an instance of an object").

                          I think the key datum here is that two errors occurred at the same time (i.e., OnStartUp was not being called for either indicator) on a single chart refresh.

                          So, there's your next clue for those developers & support people with access to NinjaTrader source code: What would cause this type of error to occur for more than one indicator?

                          Comment


                            #14
                            KBJ, I talked to development and unfortunately no clues or scenarios could be formulated from that angle, we would need to test a reproduce scenario to further look into from our end. If the call fails, we would definitely expect a log entry / exception on that though.
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by adeelshahzad, Today, 03:54 AM
                            5 responses
                            32 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by stafe, 04-15-2024, 08:34 PM
                            7 responses
                            32 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by merzo, 06-25-2023, 02:19 AM
                            10 responses
                            823 views
                            1 like
                            Last Post NinjaTrader_ChristopherJ  
                            Started by frankthearm, Today, 09:08 AM
                            5 responses
                            21 views
                            0 likes
                            Last Post NinjaTrader_Clayton  
                            Started by jeronymite, 04-12-2024, 04:26 PM
                            3 responses
                            43 views
                            0 likes
                            Last Post jeronymite  
                            Working...
                            X