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:
| Member | Purpose |
|---|---|
series[0] | Get or set the current bars-ago value. |
Count | Number 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:
| Type | Description |
|---|---|
DataSeriesType.Tick | Tick bars. |
DataSeriesType.Second | Second bars. |
DataSeriesType.Minute | Minute bars. |
DataSeriesType.Hour | Hour bars. |
DataSeriesType.Day | Daily bars. |
DataSeriesType.Week | Weekly bars. |
DataSeriesType.Month | Monthly 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
| Problem | Fix |
|---|---|
Reading Close[1] on the first bar | Guard with if (CurrentBar < 2) return;. |
Using DateTime.Now and getting a compile issue | Use 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 ready | Guard CurrentBars[1]. |