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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by manueldecastro, Yesterday, 10:26 AM
    4 responses
    18 views
    0 likes
    Last Post manueldecastro  
    Started by TraderIqbal, 10-20-2023, 10:12 AM
    2 responses
    119 views
    0 likes
    Last Post Funnywo
    by Funnywo
     
    Started by Creamers, 04-27-2024, 05:32 AM
    12 responses
    72 views
    0 likes
    Last Post Creamers  
    Started by fredericlebre, Today, 01:19 AM
    0 responses
    8 views
    0 likes
    Last Post fredericlebre  
    Started by TraderJA, Today, 12:06 AM
    0 responses
    11 views
    0 likes
    Last Post TraderJA  
    Working...
    X