Count
public int CountReturns the number of elements in the series. The DateTimes collection contains the same number of DateTimes. Derived classes maintain their associated data synchronized to these DateTimes.
API documentation, members, signatures, and C# examples.
Find classes, members, and documentation.
TimeSeriesBase is the common base class used by TimeSeries and BarHistory. It provides shared functionality for working with data synchronized to a List of DateTimes. Two important concrete classes derive from TimeSeriesBase:
double valuesDateSynchedList<double>. Important inherited members commonly used with TimeSeriesBase instances include the following.public int CountReturns the number of elements in the series. The DateTimes collection contains the same number of DateTimes. Derived classes maintain their associated data synchronized to these DateTimes.
public virtual List<DateTime> DateTimesContains the DateTime corresponding to each element in the series. Derived classes maintain their own values synchronized with this collection, allowing the same index to be used to access both a DateTime and its corresponding data.
public DateTime EndDateReturns the final DateTime in DateTimes.
Returns DateTime.MaxValue if the collection is empty.
public int IndexOf(DateTime dt, bool exactMatchOnly = false)Returns the index corresponding to dt. If exactMatchOnly is false and an exact match does not exist, the method returns the index immediately following the closest earlier DateTime, provided the requested DateTime falls within the range of the series. Returns -1 if the DateTime falls outside the series or if exactMatchOnly is true and no exact match exists.
public DateTime StartDateReturns the first DateTime in DateTimes.
Returns DateTime.MinValue if the collection is empty.
public TimeSpan TimeSpanReturns the amount of time covered by the DateTimes in the series. Returns a zero TimeSpan if fewer than two DateTimes are available.
public ConcurrentDictionary<string, object> CacheA generic cache Dictionary that can be used to associate arbitrary objects with the TimeSeriesBase instance. Indicators can use this Cache to share related calculations and avoid recalculating the same data.
public TimeSpan DetermineMarketCloseTime()Attempts to determine the market close time from the DateTimes contained in the series. The method examines transitions between trading days and returns the latest observed time of day immediately preceding a new date. Returns a zero TimeSpan if the series contains no data.
public TimeSpan DetermineMarketOpenTime()Attempts to determine the market open time from the DateTimes contained in the series. For intraday data, the method examines the first bar of each trading day. When the detected scale is minute-based, it adjusts the first bar's timestamp backward by one interval to estimate the actual market open time. Returns a zero TimeSpan if the series contains no data.
public HistoryScale DetermineScale(bool useBarHistory)Attempts to determine the HistoryScale represented by the DateTimes in the series. If useBarHistory is true and this instance is a BarHistory, the method returns the BarHistory's assigned Scale directly. Otherwise, it examines the spacing between DateTimes and attempts to identify the data as:
public string EndDateDisplayReturns EndDate formatted as a short date/time string for display purposes.
Returns an empty string if EndDate is DateTime.MaxValue.
public double FirstValueReturns the first value in the series.
Returns Double.NaN if the series contains no values.
public virtual bool IsUpToDate(DateTime endDate)Returns true if the series appears to contain data through the requested endDate. The base implementation evaluates the data using the US Stock Market and a Daily scale. BarHistory overrides this method so that the test can account for the BarHistory's actual market and scale, including market holidays, trading hours, and intraday data.
public double LastChangeReturns the change between the final two values in the series:
LastValue - PreviousValue
Returns Double.NaN if the series contains fewer than two values.
public double LastChangePctReturns the percentage change between the final two values in the series.
Returns Double.NaN if the series contains fewer than two values.
public double LastValueReturns the final value in the series.
Returns Double.NaN if the series contains no values.
public double SortTokenContains a temporary numeric value that can be used when sorting TimeSeriesBase instances. WealthLab uses this property internally in certain position sizing and participant-sorting operations. The default value is 0.
public string StartDateDisplayReturns StartDate formatted as a short date/time string for display purposes.
Returns an empty string if StartDate is DateTime.MinValue or DateTime.MaxValue.
public bool SuppressLabelsDetermines whether labels should be suppressed when the series is plotted on a chart. The default value is false.
public double TotalProfitReturns the total change in the series:
LastValue - FirstValue
public double TotalProfitPercentReturns TotalProfit as a percentage of FirstValue.
Returns Double.NaN if FirstValue is zero.
public object UserDataProvides a general-purpose property for associating custom data with a TimeSeries or BarHistory instance.
You can store any object, including primitive values such as an int or double.
public double UserDataAsDoubleReturns UserData cast to a double.
Returns Double.NaN if UserData is null.
The value stored in UserData must be compatible with a direct cast to double.
public int UserDataAsIntReturns UserData cast to an int.
Returns 0 if UserData is null.
The value stored in UserData must be compatible with a direct cast to int.
public bool WasPlottedIndicates whether the series has been plotted. WealthLab uses this property internally when managing charted TimeSeries and indicators. The default value is false.
Ask the community or explore custom development services.