---
id: "M:cAlgo.API.CustomBar.#ctor(System.DateTime,System.Double,System.Double,System.Double,System.Double,System.Int64)"
kind: "constructor"
type: "T:cAlgo.API.CustomBar"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBar/Constructor/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# CustomBar constructor

Member of [CustomBar](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBar/index.md).

## CustomBar(DateTime time, double open, double high, double low, double close, long volume)

Creates a new custom bar.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
public CustomBar(DateTime time, double open, double high, double low, double close, long volume)
```

Python:

```python
CustomBar(time: DateTime, open: float, high: float, low: float, close: float, volume: int)
```

### Parameters

- `time` (`DateTime`, Python `DateTime`): Open time
- `open` (`double`, Python `float`): Open price
- `high` (`double`, Python `float`): High price
- `low` (`double`, Python `float`): Low price
- `close` (`double`, Python `float`): Close price
- `volume` (`long`, Python `int`): Volume amount

Available since cAlgo.API 5.3.

### Examples

C#:

```csharp
var lastBar = MarketData.GetBars(TimeFrame.Hour, "EURUSD").LastBar;
var customBar = new CustomBar(lastBar.OpenTime, lastBar.Open, lastBar.High, lastBar.Low, lastBar.Close, (long)lastBar.TickVolume);
Print("Custom bar created at {0}", customBar.Time);
```

Python:

```python
lastBar = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD").LastBar
customBar = CustomBar(lastBar.OpenTime, lastBar.Open, lastBar.High, lastBar.Low, lastBar.Close, int(lastBar.TickVolume))
api.Print(f"Custom bar created at {customBar.Time}")
```

