---
id: "T:cAlgo.API.CustomBars"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/"
---

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

# CustomBars (interface)

Represents a mutable collection of OHLC bars that will be used for a custom time frame / symbol.

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.

## Definition

```csharp
public interface CustomBars
```

Available since cAlgo.API 5.3.

## Examples

C#:

```csharp
var customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
var sourceBars = MarketData.GetBars(TimeFrame.Hour, "EURUSD");
customBars.AppendBars(sourceBars.Select(bar => new CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume)));
Print("{0} custom bars for {1}, last close {2}", customBars.Bars.Count, customBars.Symbol.Name, customBars.Bars.LastBar.Close);
```

Python:

```python
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
sourceBars = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD")
for bar in sourceBars:
    customBars.AppendBar(CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, int(bar.TickVolume)))
api.Print(f"{customBars.Bars.Count} custom bars for {customBars.Symbol.Name}, last close {customBars.Bars.LastBar.Close}")
```

## Methods

- `void AppendBar(CustomBar bar)` — Appends a new bar to the end of bars collection. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/AppendBar/index.md)
- `void AppendBars(IEnumerable<CustomBar> bars)` — Appends a collection of bars to the end of bars collection. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/AppendBars/index.md)
- `void PrependBar(CustomBar bar)` — Prepends a new bar to the start of bars collection. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/PrependBar/index.md)
- `void PrependBars(IEnumerable<CustomBar> bars)` — Prepends a collection of bars to the start of bars collection. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/PrependBars/index.md)
- `void UpdateLastBar(double open, double high, double low, double close, long volume)` — Updates the last bar. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/UpdateLastBar/index.md)

## Properties

- `Bars Bars {get;}` — Gets readonly bars. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/Bars/index.md)
- `bool IsLoaded {get;}` — Gets IsLoaded status, If true it means custom bars is being used and can't be removed. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/IsLoaded/index.md)
- `Symbol Symbol {get;}` — Gets symbol of custom bars. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/Symbol/index.md)
- `TimeFrame TimeFrame {get;}` — Gets timeframe of custom bars. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/TimeFrame/index.md)

## Events

- `event Action<CustomBarsNeedsMoreEventArgs> NeedsMore;` — Occurs when user scrolls back on a custom bars chart. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/NeedsMore/index.md)

