E.g., when I copy a strategy to a new editor I also want my defaults for things like "Data Series Value" and "Min bars required" to come along with it, just as the defaults I assign to custom parameters are defined in the code.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Set general parameter defaults in code
Collapse
X
-
Set general parameter defaults in code
For non-custom strategy properties/parameters how can we set the default value in code?
E.g., when I copy a strategy to a new editor I also want my defaults for things like "Data Series Value" and "Min bars required" to come along with it, just as the defaults I assign to custom parameters are defined in the code.Tags: None
-
Hi dbooksta,
For items that are not public properties, these need to be set in Initialize().
For example:
In general, if you look up the special variable in the help guide, the placement of the variable will be in the example.Code:protected override void Initialize() { BarsRequired = 20; }
Below is a link to the help guide on BarsRequired.
http://www.ninjatrader.com/support/h...srequired2.htm
Also, take a look at Calculate on bar close.
http://www.ninjatrader.com/support/h...onbarclose.htmChelsea B.NinjaTrader Customer Service
-
Hello dbooksta,
Here is a link to the alphabetical reference of methods, special variables, and collections so that you may look up items alphabetically instead of using the search feature of the help guide.
http://www.ninjatrader.com/support/h..._reference.htm
For Value(s[0]) you can set this in OnBarUpdate, OnPositionUpdate, OnMarketData, OnMarketDepth, and OnExecution.
Value is set with:
Value.Set(11.11);
Below is a link to Value.
http://www.ninjatrader.com/support/h.../nt7/value.htmChelsea B.NinjaTrader Customer Service
Comment
-
Hi dbooksta,
The primary data series (bar type and interval) will be the dataseries of the chart (or if you are adding a strategy to the Strategies tab of the Control Center, the dataseries will be the dataseries chosen in the strategy's parameters).
You are able to add additional dataseries using the Add() method.
For example:
Add("ES 06-14", PeriodType.Minute, 5);
Below is a link to the help guide on Add().
http://www.ninjatrader.com/support/h...s/nt7/add3.htm
(edit)
Further you should look into BarsInProgress and BarsArray to see how to find which dataseries is processing and how to call an indicator using a secondary series.
http://www.ninjatrader.com/support/h...inprogress.htm
http://www.ninjatrader.com/support/h.../barsarray.htmChelsea B.NinjaTrader Customer Service
Comment
-
My objective is to have the Strategy code tell the Control Center what default bar type and interval to use, so that when I copy or paste Strategy code I (or collaborators) don't have to remember to manually set those values in the Control Center. Based on what you've said it sounds like this is not presently possible?Originally posted by NinjaTrader_ChelseaB View PostThe primary data series (bar type and interval) will be the dataseries of the chart (or if you are adding a strategy to the Strategies tab of the Control Center, the dataseries will be the dataseries chosen in the strategy's parameters).
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment