IndicatorDataSeries


Summary

Represents a mutable array of values. An extension of DataSeries used to represent indicator values.

Syntax

public interface IndicatorDataSeries : DataSeries, IEnumerable

Members

NameTypeSummary
this[int index] PropertyGets or sets the value at the specified index.

Example 1

//This will be the output result of your indicator
[Output("Result", Color = Colors.Orange)]
public IndicatorDataSeries Result { get; set; }

Example 2

//  The following example is the calculation of the simple moving average
//  of the median price
[Output("Result")]
public IndicatorDataSeries Result { get; set; }
private IndicatorDataSeries _dataSeries;
private SimpleMovingAverage _simpleMovingAverage;
protected override void Initialize()
{
    _dataSeries = CreateDataSeries();
    _simpleMovingAverage = Indicators.SimpleMovingAverage(_dataSeries, 14);
}
public override void Calculate(int index)
{
    _dataSeries[index] = (MarketSeries.High[index] + MarketSeries.Low[index])/2;
    Result[index] = _simpleMovingAverage.Result[index];
}

Example 3

using cAlgo.API;
namespace cAlgo
{
    // This sample shows how to use an indicator data series
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class IndicatorDataSeriesSample : Indicator
    {
        private IndicatorDataSeries _internalSeries;
        [Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Main { get; set; }
        protected override void Initialize()
        {
            // If an indicator data series doesn't has the Output attribute then you must create it manually
            _internalSeries = CreateDataSeries();
        }
        public override void Calculate(int index)
        {
            _internalSeries[index] = Bars.HighPrices[index];
            Main[index] = _internalSeries[index] - Bars.LowPrices[index];
        }
    }
}
Reference