Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Input Variables 0

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

    Input Variables 0

    Hello,

    when I create a strategy, I always get 0 values ​​as standard input. How can I change these default values? Thank you for the support

    #2
    Hello Lopat,

    Thank you for your post.

    Default values for properties in the script are set within OnStateChange() > State.SetDefaults, since the logic will be processed each time the script is initialized.

    Keep in mind, State.SetDefaults will be processed at the beginning of the lifecycle of the script, and making changes here would involve removing and readding the script as opposed to reloading with F5.

    When creating a template, the template takes any of the modified properties the user set and applies those after the script loads to bypass its normal defaults if a default template is used.

    Please see the example below on how to use State.SetDefaults within a script.

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    // Calculate once at the end of every single bar
    Calculate = Calculate.OnBarClose;

    // Add two plots
    AddPlot(Brushes.Blue, "Upper"));
    AddPlot(Brushes.Orange, "Lower"));
    }
    }

    Additionally, here is a NinjaTrader Help Guide link with more information about State.SetDefault.


    Please let us know if we may be of further assistance.
    <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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    69 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    42 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X