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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    151 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X