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 DayTradingDEMON, Today, 09:28 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          8 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by helpwanted, Today, 03:06 AM
          2 responses
          22 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by navyguy06, Today, 09:28 AM
          0 responses
          5 views
          0 likes
          Last Post navyguy06  
          Started by rjbtrade1, 11-30-2023, 04:38 PM
          2 responses
          77 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Working...
          X