A time series of OHLCV bars
Namespace: OpenQuant.API
Assembly: OpenQuant.API (in OpenQuant.API.dll)
Syntax
| Visual Basic (Declaration) |
|---|
| <DefaultMemberAttribute("Item")> Public Class BarSeries Implements IEnumerable, ISeries |
| C# |
|---|
| [DefaultMemberAttribute("Item")] public class BarSeries : IEnumerable, ISeries |
| C++ |
|---|
| [DefaultMemberAttribute(L"Item")] ref class BarSeries : IEnumerable, ISeries |
| J# |
|---|
| /** @attribute DefaultMemberAttribute("Item") */ public class BarSeries implements IEnumerable, ISeries |
| JScript |
|---|
| public DefaultMemberAttribute("Item") class BarSeries extends IEnumerable, ISeries |
Remarks
The number of bars in the series is given by the
You can access a specific bar in the series by either using bar index in the series or bar time. The first bar in the series has zero index. The last bar in the series has Count-1 index. The last bar in the series is the most recent bar. The first and the last bars in the series can be directly accessed using
Copy Code
// using indexer
if (Bars.Count > 10)
Console.WriteLine("10 bars ago high = " + Bars[Bars.Count - 1 - 10].High);
// using the Ago method
if (Bars.Count > 10)
Console.WriteLine("10 bars ago high = " + Bars.Ago(10));
Copy Code
| |
|---|---|
public override OnBar(Bar bar)
{
if (Bars.Count > 10)
if (bar.High > Bars.HighestHigh(10))
Buy(100);
}
| |
Copy Code
| |
|---|---|
public override OnStrategyStart()
{
SMA sma = SMA(Bars, 14);
}
public override OnBar(Bar bar)
{
if (Bars.CrossesAbove(sma))
Buy(100);
}
| |
Inheritance Hierarchy
OpenQuant.API.BarSeries