listOfSeriesValues.Add(Rng0Rng1); in OnBarUpdate scope,
with private List<double> listOfSeriesValues; at class level scope
and List<double> listOfSeriesValues = new List<double>(); in State.Dataloaded scope.
(Just those 3 steps without the stackoverflow list mode at class level scope method yet.)
It throws those errors:
Testa.cs The best overloaded method match for 'System.Collections.Generic.List<double>.Add(doubl e)' has some invalid arguments CS1502 427 4
Testa.cs Argument 1: cannot convert from 'NinjaTrader.NinjaScript.Series<double>' to 'double' CS1503 427 27
The New List listOfSeriesValues needs/expects a single double value, but cannot add it to its elements from Rng0Rng1 <Series> Double because
Rng0Rng1 ('NinjaTrader.NinjaScript.Series<double>') cannot be converted to a single double, since it is a series of doubles, not a single double.
Is that the correct meaning? If not please correct.
I then search for how to add a series of double (Rng0Rng1) (not just a single double) to a list (listOfSeriesValues).
I found
How to add List<> to a List<>
Append a Lists Contents to another List C#
which tell to use .AddRange() instead of .Add() .
I adapted your tip to
listOfSeriesValues.AddRange(Rng0Rng1);
now I get those errors
Testa.cs The best overloaded method match for 'System.Collections.Generic.List<double>.AddRange( System.Collections.Generic.IEnumerable<double>)' has some invalid arguments CS1502 1384 19
Testa.cs Argument 1: cannot convert from 'NinjaTrader.NinjaScript.Series<double>' to 'System.Collections.Generic.IEnumerable<double>' CS1503 1384 47
Why doesn't the .AddRange() method work to add the Series double values to the list?
I understand Series<double> vs IEnumerable<double> are not the same type.
I understand Ninjatrader Series<double> are generic collections (Series<T> / IEnumerable<T>).
I understand generic collections need only one type of object
From that it seems I'd need a List Series<double> instead of a List<double> to get the same object type for both the List (listOfSeriesValues) and the Series<double> (Rng0Rng1).
but that's not working.
I checked IEnumerable (which is required with the .AddRange(IEnumerable<T>)
but apparently we can't add or remove items to the list with it
https://stackoverflow.com/questions/...let-collection
Can you please help getting the Series<double> (Rng0Rng1) added to the the List (listOfSeriesValues) ? Thanks!
I've researched about list, IEnumerable<T> (IEnumerator<T> and GetEnumerator()), .Add(), .AddRange(), List<t> Class, Dictionary
How to Create List in C#
Dotnetperls/list
C# - List<T>
How to Add Items to a C# List
How to Insert an Item into a C# List
List In C#
C# List Tutorial
C# | List Class
List<T>.AddRange(IEnumerable<T>) Method
List<T>.AddRange(IEnumerable<T>) Method
IEnumerable<T> Interface
List<T> Class
Interfaces in C# Explained - In-Depth guide on how to use interfaces
IEnumerable IEnumerator Interfaces in C#
ienumerable vs list | Difference between ienumerable and list
Can't add items to the collection
IEnumerable with List and Array C#
What is a Dictionary in C#?

Comment