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 wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
74 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Leave a comment: