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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    37 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, Yesterday, 02:41 AM
    0 responses
    17 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    25 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Working...
    X