BoolSeries

Description

Bool series is a data series that contains a Boolean value for each bar. The number of elements in this series correlates with the exact number of bars within the chart.

Create New Bool Series

In the area for the declaration of variables, simply declare a new variable:

//Variable declaration
private BoolSeries myBoolSeries;

With the OnInit() method, this variable assigns a new instance of the Bool series:

protected override void OnInit()
{
myBoolSeries = new BoolSeries(this);
CalculateOnClosedBar = true;
}

Assign Values

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

myBoolSeries.Set(true);

Writing a value in the past into the data series:

myBoolSeries.Set(int barsAgo, bool Value);

Delete Values

Removing the current value for the data series:

myBoolSeries.Reset();

Removing a value in the past from the data series:

myBoolSeries.Reset(int barsAgo);

Check Values for their Validity

myBoolSeries.ContainsValue(int barsAgo);

Read Value

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

Example

protected override void OnCalculate()
{
if (Close[0] > Open[0])
myBoolSeries.Set(true);
else
myBoolSeries.Set(false);
}

Last updated