Skip to content

TimeSeries

Summary

A series of values that represent time like MarketSeries.OpenTime

Signature

1
public abstract interface TimeSeries

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 using cAlgo.API;
 using cAlgo.API.Internals;
 namespace cAlgo
 {
     // This sample indicator shows how to use Bars OpenTimes Time Series
     [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TimeSeriesSample : Indicator
     {
         protected override void Initialize()
         {
             // Every Bars object has a time series which is the open times of bars
             var timeSeries = Bars.OpenTimes;
             Print("Count: ", timeSeries.Count);
             // You can get another bars index by using TimeSeries GetIndexByTime/GetIndexByExactTime methods
             var dailyBars = MarketData.GetBars(TimeFrame.Daily);
             var dailyBarsIndex = timeSeries.GetIndexByTime(dailyBars.OpenTimes.LastValue);
             var open = Bars.OpenPrices[dailyBarsIndex];
             Print("Daily Bars Index: ", dailyBarsIndex, " | Open: ", open);
         }
         public override void Calculate(int index)
         {
         }
     }
 }

Methods

Last

Summary

Gets the last value of this time series.

Signature

1
public abstract DateTime Last(int index)

Parameters

Name Type Description
index int

Return Value

DateTime

Examples

1
 DateTime openTime = MarketSeries.OpenTime.LastValue;

GetIndexByExactTime

Summary

Find the index in the different time frame series.

Signature

1
public abstract int GetIndexByExactTime(DateTime dateTime)

Parameters

Name Type Description
dateTime DateTime The open time of the bar at this index

Return Value

int

Examples

1
 var indexSeries2 = indexSeries2.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime.LastValue);

GetIndexByTime

Summary

Find the index in the different time frame series.

Signature

1
public abstract int GetIndexByTime(DateTime dateTime)

Parameters

Name Type Description
dateTime DateTime The open time of the bar at this index

Return Value

int

Examples

1
 var indexSeries2 = indexSeries2.OpenTime.GetIndexByTime(MarketSeries.OpenTime.LastValue);

Properties

Item

Signature

1
public abstract DateTime Item {get;}

Return Value

DateTime

LastValue

Summary

Gets the last value of this time series.

Signature

1
public abstract DateTime LastValue {get;}

Return Value

DateTime

Examples

1
 DateTime openTime = MarketSeries.OpenTime.LastValue;

Count

Summary

Gets the number of elements contained in the series.

Signature

1
public abstract int Count {get;}

Return Value

int