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 cmoran13, Yesterday, 01:02 PM
    0 responses
    27 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    18 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X