Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on setting default values for user-entered property parameters

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

    Question on setting default values for user-entered property parameters

    Hello,

    The NT8 Help Guide indicates that the OnStateChange() if (State == State.SetDefaults) block should be kept "as lean as possible."

    I cannot seem to find why this block of code's size has any special need to be small compared to the rest of a script. This get set logic is only loaded and processed once when the script is initialized. I am trying to make my strategies as efficient as possible, and this is just something that I have been wondering about.

    All code should be as concise as possible, but should some these values be set elsewhere in the script like in if (Bar.IsFirstBarOfSession)? My scripts do not change the initial values of my property parameters outside of if (State == State.SetDefaults). Is there something specific to this state that is taxing on a computer's resources?

    Thank you for any info.

    #2
    Hello 9817_dynamic,

    Thank you for your post.

    State.SetDefaults in OnStateChange() should be kept as lean as possible to prevent logic from processing superfluously and causing problems unrelated to the configured instance. Only properties which need to be displayed on the UI should be set in this state.

    See the help guide documentation for more information about NinjaScript States and their Lifecycle.
    NinjaScript Lifecycle - https://ninjatrader.com/support/help...fecycle_of.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    23 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X