Modified on 2016/12/28 11:38 by Eugene — Categorized as: Community Components


public static double[] ToArray(this DataSeries ds)

Parameter Description

dsDataSeries object


LINQ provides a convenient and terse way to write SQL-like queries, allowing to filter, aggregate, group, sort and so on. While Wealth-Lab's DataSeries doesn't support LINQ natively, Community.Components users can employ the so called extension method .ToArray() to run LINQ queries on DataSeries.

There also is a companion method ToList with identical syntax.


The following quick example shows the average price of a DataSeries by virtue of LINQ's Average function.

Note: Add reference to System.Core before using the sample code:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using System.Linq;
/*** Requires installation of Community.Components Extension from > Extensions, 2012.10 or later***/

namespace WealthLab { public class MyStrategy : WealthScript { protected override void Execute() { var ds2List = Bars.Close.ToArray(); var dsAverage = ds2List.Average( i => i ); PrintDebug(dsAverage); } } }