Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange way Initialization gets triggered in Strategy

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

    Strange way Initialization gets triggered in Strategy

    Hello,

    I, like anyone else, initialize the whole bunch of variables in Initialize() method. Recently I added Print line there with the version number just to keep track.

    Print("Strategy Version 5");

    I only expected to see this line in output window when I enable the strategy, which it does of course. However, if I right mouse click on the chart and go to strategies section to check which parameters I have set, I see the output of the Print command in output window. The mere fact just going to strategy section on the chart triggers it. At first I was scared because initializing variables on the middle of the trade would ruin my logic, but all seems to be working fine.

    My question is what Initialize() method is triggered than to print that line? Is it a different memory space from the one where strategy is running?

    Thanks,
    redduke

    #2
    Hello redduke,

    NinjaTrader creates an instance of the script any time the Strategies window is opened (to get a list of scripts), when the script is selected (to pull the default values), when the script is added, and when the script is enabled.

    Below is a forum post that describes the life-cycle of a script.


    This is for NinjaTrader 8 but the process is the same for NinjaTrader 7.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for the response. So if I have a strategy already enabled, its instance is untouched when I go back to strategy section just to browse via right clicking on the chart?

      Thanks

      Comment


        #4
        Hello RedDuke,

        That instance of the script will be untouched. But a new instance will be created when the strategy window is opened.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks a lot

          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