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
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Input Variables 0
Collapse
X
-
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
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by manueldecastro, Yesterday, 10:26 AM
|
4 responses
18 views
0 likes
|
Last Post Today, 02:56 AM | ||
Started by TraderIqbal, 10-20-2023, 10:12 AM
|
2 responses
119 views
0 likes
|
Last Post
by Funnywo
Today, 02:03 AM
|
||
Started by Creamers, 04-27-2024, 05:32 AM
|
12 responses
72 views
0 likes
|
Last Post
by Creamers
Today, 01:50 AM
|
||
Started by fredericlebre, Today, 01:19 AM
|
0 responses
8 views
0 likes
|
Last Post Today, 01:19 AM | ||
Started by TraderJA, Today, 12:06 AM
|
0 responses
11 views
0 likes
|
Last Post
by TraderJA
Today, 12:06 AM
|
Comment