Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 lightsun47, Today, 03:51 PM
          0 responses
          2 views
          0 likes
          Last Post lightsun47  
          Started by 00nevest, Today, 02:27 PM
          1 response
          8 views
          0 likes
          Last Post 00nevest  
          Started by futtrader, 04-21-2024, 01:50 AM
          4 responses
          41 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          13 views
          0 likes
          Last Post bltdavid  
          Started by port119, Today, 02:43 PM
          0 responses
          8 views
          0 likes
          Last Post port119
          by port119
           
          Working...
          X