---
id: "M:cAlgo.API.CustomBars.PrependBars(System.Collections.Generic.IEnumerable{cAlgo.API.CustomBar})"
kind: "method"
type: "T:cAlgo.API.CustomBars"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/PrependBars/"
---

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

# CustomBars.PrependBars

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

## PrependBars(IEnumerable<CustomBar> bars)

Prepends a collection of bars to the start of bars collection.

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
void PrependBars(IEnumerable<CustomBar> bars)
```

Python:

```python
customBars.PrependBars(bars: Iterable[CustomBar]) -> None
```

### Parameters

- `bars` (`IEnumerable<CustomBar>`, Python `Iterable[CustomBar]`): New bars

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");
var loadedCount = sourceBars.LoadMoreHistory();
customBars.PrependBars(sourceBars.Take(loadedCount).Select(bar => new CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume)));
```

Python:

```python
from System import Array
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
sourceBars = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD")
loadedCount = sourceBars.LoadMoreHistory()
olderBars = [CustomBar(sourceBars[i].OpenTime, sourceBars[i].Open, sourceBars[i].High, sourceBars[i].Low, sourceBars[i].Close, int(sourceBars[i].TickVolume)) for i in range(loadedCount)]
customBars.PrependBars(Array[CustomBar](olderBars))
```

