---
id: "M:cAlgo.API.CustomBars.PrependBar(cAlgo.API.CustomBar)"
kind: "method"
type: "T:cAlgo.API.CustomBars"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/PrependBar/"
---

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

# CustomBars.PrependBar

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

## PrependBar(CustomBar bar)

Prepends a new bar 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 PrependBar(CustomBar bar)
```

Python:

```python
customBars.PrependBar(bar: CustomBar) -> None
```

### Parameters

- `bar` (`CustomBar`, Python `CustomBar`): New bar

Available since cAlgo.API 5.3.

### Examples

C#:

```csharp
var customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
var openTime = customBars.Bars.Count > 0 ? customBars.Bars[0].OpenTime.AddHours(-1) : Server.Time.Date;
customBars.PrependBar(new CustomBar(openTime, 1.0830, 1.0855, 1.0825, 1.0850, 900));
```

Python:

```python
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
openTime = customBars.Bars[0].OpenTime.AddHours(-1) if customBars.Bars.Count > 0 else api.Server.Time.Date
customBars.PrependBar(CustomBar(openTime, 1.0830, 1.0855, 1.0825, 1.0850, 900))
```

