There is no problem with stocks or currency pairs, while how may I avoid to necessarily change my codes every month when using futures, whose symbol is (for istance) "ES 03-15" ?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Instrument.MasterInstrument.Name
Collapse
X
-
Instrument.MasterInstrument.Name
I often use instructions likeif (Instrument.MasterInstrument.Name = ".....")or
if (Instrument.FullName = ".....")in order to identify specific instruments.
There is no problem with stocks or currency pairs, while how may I avoid to necessarily change my codes every month when using futures, whose symbol is (for istance) "ES 03-15" ?Tags: None
-
Hello Mauripasto,
Thank you for your post.
There are a couple different ways to do this however I believe the setup I have provided below will meet your needs here
We are getting the ES naming convention string and adding an additional space which will serve for between ES and the Contract MonthCode:string instrumentName = Instrument.FullName.Substring(0, Instrument.MasterInstrument.Name.Length + 1); string fullInstrument = string.Concat(instrumentName, ContractMonth); if(Instrument.FullName == fullInstrument) Print("HIT");
We then use string.Concat() to combine the two strings, ContractMonth being a public string that can be set from the properties of the indicator
I then added the if statement to test the string name and printed Hit to confirm that it was working as expected.
Let me know if I can be of further assistance.Cal H.NinjaTrader Customer Service
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
52 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
23 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
16 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
23 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
24 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment