Skip to content

IndicatorDataSeries

Summary

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

Signature

1
public abstract interface IndicatorDataSeries

Namespace

cAlgo.API

Properties

Name Description
Item { get; set; }

Examples

1
2
3
 //This will be the output result of your indicator
 [Output("Result", Color = Colors.Orange)]
 public IndicatorDataSeries Result { get; set; }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 //  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];
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 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];
         }
     }
 }

Last update: November 25, 2022

Comments