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

# 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 gemify, 11-11-2022, 11:52 AM
      6 responses
      803 views
      2 likes
      Last Post ultls
      by ultls
       
      Started by ScottWalsh, Today, 04:52 PM
      0 responses
      3 views
      0 likes
      Last Post ScottWalsh  
      Started by ScottWalsh, Today, 04:29 PM
      0 responses
      7 views
      0 likes
      Last Post ScottWalsh  
      Started by rtwave, 04-12-2024, 09:30 AM
      2 responses
      22 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by tsantospinto, 04-12-2024, 07:04 PM
      5 responses
      70 views
      0 likes
      Last Post tsantospinto  
      Working...
      X