DateTimeSeries

Description

Date time series is a DataSeries that can record a date-time value for each bar. The number of elements in this series corresponds to the number of bars in the chart.

Create a New Data Series

Create a new variable in the declaration area:

//Variable declaration
private DateTimeSeries myDataSeries;

Assign a new instance of DateTimeSeries for the variable with the OnInit() method:

protected override void OnInit()
{
myDataSeries = new DateTimeSeries(this);
CalculateOnClosedBar = true;
}

Assign Values

Assigning a value to the current position of the data series:

myDataSeries.Set(DateTime Value);

Writing a value from the past into the data series:

myDataSeries.Set(int barsAgo, DateTime Value);

Delete Values

Removing the current value from the data series:

myDataSeries.Reset();

Remove a past value from the data series:

myDataSeries.Reset(int barsAgo);

Check Values for their Validity

myDataSeries.ContainsValue(int barsAgo);

Read Value

Print ("For the bar from " + Time[0] + " ago the value of the data series is: " + myDataSeries[0]);

Example

//Saves the difference of -6 hours (eastern time, New York) for a time zone conversion
myDataSeries.Set(Time[0].AddHours(-6));

Last updated