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 bowling, Today, 06:16 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by systemtrader4, Today, 01:54 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by Futurestrader00, Today, 01:54 AM
      1 response
      25 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by timmbbo, Today, 01:40 AM
      2 responses
      10 views
      0 likes
      Last Post NT-Roland  
      Started by BGWTEX, Yesterday, 07:20 PM
      0 responses
      7 views
      0 likes
      Last Post BGWTEX
      by BGWTEX
       
      Working...
      X