Summary
A series of values that represent time like MarketSeries.OpenTime
Syntax
public interface TimeSeries : IEnumerable
Members
Name | Type | Summary |
---|---|---|
Count | Property | Gets the number of elements contained in the series. |
GetIndexByExactTime | Method | Find the index in the different time frame series. |
GetIndexByTime | Method | Find the index in the different time frame series. |
Last | Method | Access a value in the data series certain number of bars ago. |
LastValue | Property | Gets the last value of this time series. |
this[int index] | Property | Returns the DateTime value at the specified index. |
Example 1
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) { } } }