Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.htmPaul H.NinjaTrader Customer Service
-
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
-
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.
Originally 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.
Paul H.NinjaTrader Customer Service
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 goodknight777, Today, 08:43 AM
|
1 response
4 views
0 likes
|
Last Post Today, 09:25 AM | ||
Started by kramnor2001, Yesterday, 02:30 PM
|
3 responses
20 views
0 likes
|
Last Post
by kramnor2001
Today, 09:20 AM
|
||
Started by ninza33, Today, 09:10 AM
|
0 responses
2 views
0 likes
|
Last Post
by ninza33
Today, 09:10 AM
|
||
Started by Padan, Today, 02:02 AM
|
3 responses
11 views
0 likes
|
Last Post Today, 08:54 AM | ||
Started by Tim-c, Today, 08:36 AM
|
1 response
3 views
0 likes
|
Last Post Today, 08:45 AM |
Comment