• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Coursocied67, Today, 04:02 AM
      0 responses
      2 views
      0 likes
      Last Post Coursocied67  
      Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
      7 responses
      35 views
      0 likes
      Last Post DaveS
      by DaveS
       
      Started by scfnkysx, Today, 12:30 AM
      0 responses
      4 views
      0 likes
      Last Post scfnkysx  
      Started by jimloforkocv, Today, 12:16 AM
      0 responses
      4 views
      0 likes
      Last Post jimloforkocv  
      Started by claxxical, Yesterday, 10:00 PM
      0 responses
      9 views
      0 likes
      Last Post claxxical  
      Working...
      X