Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

# of times State.SetDefaults is referenced with each OnStateChange?

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

    # of times State.SetDefaults is referenced with each OnStateChange?

    Hi there,

    This is a probably a softball question, but I'm going to ask it anyway.

    How many times are the SetDefaults and State.Configure areas called within the lifecycle of a NinjaScript strategy running through the day? My impression is that the default is to reference them every time there is a state change w/ OnStateChange().

    Is there any sort of performance hit with that, or is it negligible?
    Please let me know when you have a moment.

    Yours,
    Spiderbird
    Last edited by Spiderbird; 12-18-2017, 12:58 PM. Reason: (grammar)

    #2
    Nevermind!

    I just figured it out. I had to dig a bit into the existing help files for NT8 to get a proper reference. Pulled the trigger to soon on a forum thread.

    Comment


      #3
      Hello,
      Thanks for your post and I am happy to hear that you figured it out.

      For future reference, State.SetDefaults can be called multiple times since it will always be called when displaying objects in a UI list such as the Strategies dialogue window; this is because temporary objects are created for the purpose of UI display. State.Configure is called after a user adds an object to the applied list of objects and presses the OK or Apply button. This state is called only once for the life of the object.

      For anyone else that is interested, I have included some useful help guide links below that go over good practices for state management, performance considerations, and the NinjaScript Lifecycle.

      NinjaScript- Best Practices
      https://ninjatrader.com/support/help..._practices.htm

      OnStateChange()
      https://ninjatrader.com/support/help...tatechange.htm

      Understanding the NinjaScript Lifecycle
      https://ninjatrader.com/support/help...fecycle_of.htm

      Please let me know if you have any further questions.
      Josh G.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      77 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X