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
Alternating parameters in Ninja
Collapse
X
-
Originally posted by ct View Post
-
Thank you for this additional information ct. For reference, I am assuming you are referring to Python tuples (publicly available documentation https://www.tutorialspoint.com/python/python_tuples.htm) and that our question is how we can alternate between different types within a single list.
Every object in C# descends from an object whose type is "object". So this works.
Code:[FONT=Courier New] List<object> tupleExample = new List<object>(); tupleExample.Add(2.3); tupleExample.Add(4); tupleExample.Add("five six"); SMA sevenEightNine = new SMA(); tupleExample.Add(sevenEightNine); foreach(object i in tupleExample) { Print(i.ToString()); }[/FONT]
So in fewer words, strong typing saves us writing a lot of code in some environments, and that is one reason why many people code this way. Many coders write in many languages and environments and like to carry conventions between them.
So, a more strongly typed approach to what you are trying to do would be to create a structure which can hold all of these things, and make a list of them. For example,
Code:[FONT=Courier New]struct Node { double val1; int val2; string val3; Indicator val4; }[/FONT]
Leave a comment:
-
Hello ct, and thank you for your question. So I may better assist, can you provide a working two array example? This will make it easier to provide the best assistance possible.
Leave a comment:
-
Alternating parameters in Ninja
Scenario:
Is there a way to create a user defined parameter using alternating array values in Ninja?
eg: (2.3, NQ, 1, YM, .5, ES). (number1, Value1, Number2, Value2)
I know I can use two arrays or lists but didn't know if there was another method available I could use.
CheersTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
20 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Leave a comment: