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

Strategy Builder Variable Initialization Location Not Using Best Practice?

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

    Strategy Builder Variable Initialization Location Not Using Best Practice?

    Hello,

    The Strategy Builder variable initialization location in the code output seems to be in wrong place, per the "NinjaScript Best Practices" web page's ( http://ninjatrader.com/support/helpG..._practices.htm ) "State management practices" section, which states:

    Do not set variables at the class level unless they are constant. You should delay setting or resetting variables until the State has reached State.Configure.
    This web page also shows examples of initializing class level variables in the "else if (State == State.Configure)" section.

    The Strategy Builder isn't following this advice, and instead is putting class level variable initialization in the "else if (State == State.SetDefaults)" section.

    Question: Is the NinjaScript Best Practices web page correct, or is the Strategy Builder correct (or are both correct)?

    Thank you very much in advance,

    EquityTrader

    #2
    Hello EquityTrader,

    Thank you for writing in.

    The NinjaScript Best Practices is correct.

    You point out a limitation of the strategy builder, in which variables are set in State.SetDefaults rather than State.Configure.

    I will put a feature request for variables to be set in State.Configure.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_AlanP,

      Perfect. Thank you very much for your excellent help. I will be sure to put all my variable initialization statements in State.Configure, per your advice, and will not do it the way that the Strategy Builder does it.

      Thanks again,

      EquityTrader

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by thanajo, 05-04-2021, 02:11 AM
      4 responses
      470 views
      0 likes
      Last Post tradingnasdaqprueba  
      Started by aa731, Today, 02:54 AM
      0 responses
      4 views
      0 likes
      Last Post aa731
      by aa731
       
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,237 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      6 views
      0 likes
      Last Post thread
      by thread
       
      Working...
      X