Transfer multiple values from VariableSeries object to C# array  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
mattbarsotti
Posts: 3
Joined: 14 Sep 2018
Has thanked: 1 time

Transfer multiple values from VariableSeries object to C# array

Postby mattbarsotti » 14 Sep 2018

I feel fairly confident this is a question that has been asked and answered, but it proved difficult to find in the forum.

I currently have a for-loop that copies a range of values from a VariableSeries object to a C# array. That works fine, but it is cumbersome and suboptimal. Is there a simpler method for doing this in a single command?

For simplicity, I'd simply like to take the most recent 50 values from a VariableSeries and copy them into a double array.

Much thanks,
Matt

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Transfer multiple values from VariableSeries object to C# array

Postby Henry MultiСharts » 19 Sep 2018

Hello Matt,

There's no prebuilt method for that.

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 76 times
Contact:

Re: Transfer multiple values from VariableSeries object to C# array  [SOLVED]

Postby fbertram » 30 Oct 2018

You can use Linq to do what you need. Try something along the lines of this:

Code: Select all

double[] myArray = Enumerable.Range(0, 25)
.Select(t => Bars.Close[t])
.ToArray();

Hope this helps,
cheers

Felix


Return to “MultiCharts .NET”