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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X