Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnStartUp Method

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

    OnStartUp Method

    Can someone please clarify the intent of the new OnStartUp method in NT7B8? Will it be executed only once upon loading a script, unlike the Initialize method, and will Bars objects be available for inspection?

    Thanks,

    Whitmark
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    There is a misunderstanding: Initialize() ALWAYS was called ONCE PER instance of an indicator. However, since NT held multiple temporary instances of an indicator you believed it would be called on the same instance multiple times, which actually is not true.

    OnStartUp() unlike Initialize() only would be called as an indicator actually "is used" (on chart, by strategy etc.). At the time OnStartUp() is called the Bars are already there. You could have achieved the same by coding some "startOnce" flag (I believe Josh posted some samples). However, OnStartUp() is more convenient.

    Comment


      #3
      Thanks for the new OnStartUp method and clarification. It will come in handy.

      Whitmark
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        It's safe to say OnStartUp is the "missing pair" for OnTermination.

        OnStartUp: Allocate your custom resources (file readers etc.) here
        OnTermination: Free your custom resources here

        Comment


          #5
          This is good, so now you do not have to use "MyInitialize" method at the beginning of the OnBarUpdate.
          Last edited by tamas; 02-04-2010, 03:27 AM.

          Comment


            #6
            Is there any example code yet of an indicator using OnStartUp and OnTermination? Do any of the Nt7B8 indicators use these methods. I have used the equivalent of a "startOnce" flag occaisionally but I want to make sure that I use the OnStartUp and OnTermination combination correctly. Thanks.

            Comment


              #7
              Unfortunately there is no sample yet. This is on our list.

              Comment


                #8
                Originally posted by higler View Post
                Is there any example code yet of an indicator using OnStartUp and OnTermination? Do any of the Nt7B8 indicators use these methods. I have used the equivalent of a "startOnce" flag occaisionally but I want to make sure that I use the OnStartUp and OnTermination combination correctly. Thanks.

                CustomPlotSample has the OnTermination sub. besides the same has been discussed before here. search and you will get some codes.

                on start up is also very simple

                protected override void OnStartUp()
                {
                //do your stuff here
                }


                it lets you access stuff which you cant in Initialization. a big gap filled.

                Comment


                  #9
                  Thanks, bukkan. That was helpful.

                  Comment


                    #10
                    Hello,

                    GetMinMaxValues method is executed before OnStartUp. It's possible that some resources may not be created yet.

                    I thought that OnStartUp method was the first. Which is exactly its order of execution?

                    Thanks

                    Comment


                      #11
                      cls71,

                      GetMinMaxValues is not supported NinjaScript. We can only guarantee you supported NinjaScript methods to come after OnStartUp.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Just found this topic and it seems to fit my needs. But I do have a question about it:

                        Until now I created another class in Initialize(). Is this a waste of memory as the class is created several times?

                        So should I use OnStartUp to only create the class once?


                        Thanks!

                        Comment


                          #13
                          I would move custom code to OnStartUp().

                          Comment


                            #14
                            Is there somehow any possibility to halt the strategy in this function when user input is not valid?

                            See http://www.ninjatrader-support2.com/...ad.php?t=26161

                            Comment


                              #15
                              Unfortunately this is not supported.

                              Comment

                              Latest Posts

                              Collapse

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