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
Initialize a Series of Lists
Collapse
X
-
Hello Renorail,
A new list would need to be instantiated for that bar.
Code:MySeries[0] = new List<double>(); double test_double = 4.3; MySeries[0].Add(test_double); Print(MySeries[0][0]);
- Likes 1
Leave a comment:
-
Originally posted by Renorail View PostMy assignment that looks looks like:
Code:double test_double = 4.3; MySeries[0].Add (test_double); Print(MySeries[0][0]);
Do you want a Series of doubles?
Do you want a Series of a list of doubles?
- Likes 1
Leave a comment:
-
Thank you for your response and your help. I had that earlier too and could get it through compile but then get a " Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object. So, i thought it was an initialization issue.
Maybe it is my .Add statement. I'll get a print before the assignment but not after.
For testing purposes, i have the following:
Code:private Series<List<double>> MySeries = null;
Code:else if (State == State.DataLoaded) { MySeries =new Series<List<double>>(this); }
Code:double test_double = 4.3; MySeries[0].Add (test_double); Print(MySeries[0][0]);
Leave a comment:
-
Originally posted by Renorail View PostFor example, private Series<List<double>> MySeries = new Series<List<double>>(this); returns the error 'NinjaTrader.NinjaScript.Series<System.Collections .Generic.List<double>>' does not contain a constructor that takes 0 arguments.
the declaration, keep it separate from the initial assignment.
Declare your variable, but do not initialize it (or initialize to null),
Code:private Series<List<double>> MySeries = null;
Code:protected override void OnStateChange() { switch (State) { case State.SetDefaults: MySeries = new Series<List<double>>([COLOR=#e74c3c]this[/COLOR]); break; .... } }
Leave a comment:
-
For example, private Series<List<double>> MySeries = new Series<List<double>>(); returns the error 'NinjaTrader.NinjaScript.Series<System.Collections .Generic.List<double>>' does not contain a constructor that takes 0 arguments.
Leave a comment:
-
Initialize a Series of Lists
Hello, just curious if there is an example of initializing a series of lists. I'd like to use a series of lists because i do not know how many elements are going to be computed in each bar. I found an example for creating and initializing a list (Initialize List) but for some reason I am unable to get it to work with a series of lists. Any help would be appreciated. Thanks!
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
148 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Leave a comment: