Skip to main content

Series And Bars Reference

HyperionX series use bars-ago indexing. Close[0] is the current bar, Close[1] is the previous bar, and Close[10] is ten bars ago.

Series Interface

Common series methods and properties:

MemberPurpose
series[0]Get or set the current bars-ago value.
CountNumber of values in the series.
GetValueAt(index)Reads by absolute internal index.
GetRange(startIndex, count)Reads a range by absolute index.
IsValidPoint(index)Checks whether an absolute index is valid.
SetValid(index)Marks a point as valid.

For normal script logic, prefer bars-ago access.

Custom Output Series

Indicators should register custom series before writing to them.

[Browsable(false)]
[XmlIgnore]
public Series<double> Signal { get; set; }

public override void OnStateChanged()
{
if (State == State.Configured)
{
Signal = new Series<double>();
AddSeries(Signal);
}
}

Write the current value in OnBarUpdate().

Signal[0] = Close[0] - Close[1];

Extra Data Series

Use AddDataSeries(...) in State.Configured.

AddDataSeries(DataSeriesType.Minute, 60);
AddDataSeries(DataSeriesType.Day, 1, "BTC");

Available data series types:

TypeDescription
DataSeriesType.TickTick bars.
DataSeriesType.SecondSecond bars.
DataSeriesType.MinuteMinute bars.
DataSeriesType.HourHour bars.
DataSeriesType.DayDaily bars.
DataSeriesType.WeekWeekly bars.
DataSeriesType.MonthMonthly bars.

Multi-Series Access

After an extra series is configured:

double primaryClose = Closes[0][0];
double hourlyClose = Closes[1][0];
double hourlyVolume = Volumes[1][0];
System.DateTime hourlyTime = DateTimes[1][0];

Guard both primary and secondary series.

if (CurrentBars[0] < 50 || CurrentBars[1] < 10)
return;

Use BarsInProgress when logic should only run for one series.

if (BarsInProgress != 0)
return;

Bar Timing Context

Ctx.MarketData exposes time-based helpers:

System.TimeSpan? duration = Ctx.MarketData.GetCurrentBarDuration();
System.TimeSpan? remaining = Ctx.MarketData.GetTimeRemainingInBar();
System.DateTime? openTime = Ctx.MarketData.GetCurrentBarOpenTime();
System.DateTime? closeTime = Ctx.MarketData.GetCurrentBarCloseTime();

Tick series may not have a predictable close time. These helpers can return null.

Common Mistakes

ProblemFix
Reading Close[1] on the first barGuard with if (CurrentBar < 2) return;.
Using DateTime.Now and getting a compile issueUse System.DateTime.Now; DateTime is also a bar series.
Adding a data series in OnBarUpdate()Add it in State.Configured.
Writing a series before AddSeries(...)Allocate and register in State.Configured.
Accessing Closes[1] before the extra series is readyGuard CurrentBars[1].