Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Set multiple instruments in strategy via chart UI
Collapse
X
-
Set multiple instruments in strategy via chart UI
Is it possible to directly set multiple instruments for a strategy via the strategy chart UI. I know that the chart will display multiple instruments and I know how to set this up through the UI. I know that by default the strategy will access the primary series. I do not want to hard code the secondary instrument name in an AddChart statement within the strategy. AddChart provides a facility for managing this with multiple time frames based on the same instrument, but not clear to me if (or how) to do it for multiple instruments using the same time frame.Tags: None
-
Hello jvanelli,
Thanks for your post.
When you create a script, correct it will use the charts primary series as the default data series for the script. If you want to access any other data (same or different instrument) you must use AddDataSeries() (Or variations that are bar type dependent).
In the help guide for AddDataSeries, it provides a warning that relates: "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner." Reference: https://ninjatrader.com/support/help...dataseries.htm So the bottom line is we can only recommend that you hardcode added data series.
When you add one or more data series to your script you also need to consider other potential changes to your script, these are addressed in the help guide here: https://ninjatrader.com/support/help...nstruments.htm
-
Perhaps I could read the primary instrument name during State.Configure and then execute one of several hardcoded AddDataSeries() statements dependent upon the result. Thus when I change the primary series via the chart UI, the secondary series will be set by the script. I am not interested in making this universally applicable. I only need to deal with a small number of specific cases.
Comment
-
Did you try making it a property?Originally posted by jvanelli View PostI do not want to hard code the secondary instrument name in an AddChart statement within the strategy.
Create a string property to contain the name of the instrument, then just enter this instrument name as one
of your strategy parameters.
First, use a string variable, like this, for the backing store of the property,
private string instrumentName = "ES 09-19"; // <-- hardcode default name here
Note that you can hardcode the default instrument name with your private variable, but since it's the backing
store for the string property, you'll be able to see and modify the string value inside the strategy's property
grid of parameters -- thus changing it to anything you want.
Comment
-
Hello jvanelli,
Thanks for your reply.
If your other added data series are of the same instrument as the chart bars, you can simply pass in null for the instrument name. reference: "4. For the instrument name parameter null could be passed in, resulting in the primary data series instrument being used." https://ninjatrader.com/support/help...dataseries.htmOriginally posted by jvanelli View PostPerhaps I could read the primary instrument name during State.Configure and then execute one of several hardcoded AddDataSeries() statements dependent upon the result. Thus when I change the primary series via the chart UI, the secondary series will be set by the script. I am not interested in making this universally applicable. I only need to deal with a small number of specific cases.
Comment
-
I ended up doing something similar to what bltdavid suggested. My strategy makes indicative decisions based on primary instruments (ES, YM, 6E). I read the master instrument (FullName) from the UI in State.StateConfigure and use that to select from my short list of secondary series (i.e. the micro contracts). AddSeries happens in State.StateConfigure. I have a parameter input from the UI to choose between primary instrument or secondary series for trade executions. I trade those three markets almost exclusivley so this is all I need here. Also wanted to say that NT8 is a really nice piece of work, and the support via this forum is top notch.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
51 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
127 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment