Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT runs Initialize() of ALL Strategies at once

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

    NT runs Initialize() of ALL Strategies at once

    I find it a little weird that, when the Strategies window is opened, NT executes ALL the Initialize() methods of ALL the Strategies, even when they are NOT selected (or added). Specifically, when the window is opened from a chart so a strategy can be added to the chart.

    It is somewhat frustrating to see their print stmts show up in the output window when they are NOT being executed.

    Is this behavior by design?

    #2
    Hello Lost Trader,

    Yes, this is by design. When you're choosing a strategy to run it processes Initialize() so that it can load the list.

    If you want some items to process only once you can place in the first bar of OnBarUpdate

    if (CurrentBar == 0)
    {
    //startuplogic here
    }

    NinjaTrader 7 has a new method OnStartup() for this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      No, what I wanted was to stop the strategies which are NOT running from cluttering up my output window! Oh well...

      I guess I can individually edit their Initialize() functions so that they are not so noisy!

      Comment


        #4
        I see. Yes, you would want to minimize Print() statements from the Initialize if you're getting too much in the output window.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hmmm.
          If a strategy is actively running on a chart, and I open the Strategies window just to check my settings w/o changing anything, won't NT automatically running Initialize() in the middle of an executing strategy really screw it up?

          Comment


            #6
            LostTrader, calling the Intialize() across strategies will not affect the running Strategy instance adversely.

            Comment


              #7
              I am surprised, Bertrand. Because it is CLEARLY calling the Initialize() which resets certain variables and targets. I can see the output & Trace stmts of my active strategy's Initialize() appear in the output window.

              I would suggest that y'all only execute the Initialize() if I click on a Strategy in the selection window.... That way there is no doubt & no extra unnecessary processing.

              BTW, this is on 6.5
              Last edited by Lost Trader; 08-03-2010, 07:44 AM.

              Comment


                #8
                LostTrader, we advise that sensitive logic should not be placed in the Initialize() method, instead please use the first OnBarUpdate() call (CurrentBar == 0) if you're working with 6.5 and CalculateOnBaClose = true (for false add a check for FirstTickOfBar as well then).

                Comment

                Latest Posts

                Collapse

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