Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When is "Initialize" called?

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

    When is "Initialize" called?

    I have some code I was testing that sends email notifications. I put it into the "Initialize" method of my test strategy so that I could see if it worked or not.

    However, now I find that whenever I open the "Strategy" dialog box, regardless of which strategy I am invoking, I get an email notification for my test strategy.

    Why is Initialize for my strategy that I'm not using getting called, and under what circumstances does Initialize get called? It is unexpected that it would get called when the Strategy dialog box is opened...

    thanks for any help,

    Steve

    #2
    Hello Stevent,

    Initialize() is called for all strategies and can be called more than once. It's used to load up the list of strategies whenever you need to select one from the dialog window.

    If you would like items to run only once for a particular strategy, you can do this on the first bar of the series, within OnBarUpdate.

    if (CurrentBar == 0)
    {
    //Startup logic here
    }

    NinjaTrader 7 introduces OnStartup() method for this that works similar.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    631 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    566 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X