---
id: "M:cAlgo.API.CustomBars.UpdateLastBar(System.Double,System.Double,System.Double,System.Double,System.Int64)"
kind: "method"
type: "T:cAlgo.API.CustomBars"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomBars/UpdateLastBar/"
---

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

# CustomBars.UpdateLastBar

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

## UpdateLastBar(double open, double high, double low, double close, long volume)

Updates the last 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
void UpdateLastBar(double open, double high, double low, double close, long volume)
```

Python:

```python
customBars.UpdateLastBar(open: float, high: float, low: float, close: float, volume: int) -> None
```

### Parameters

- `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 customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
if (customBars.Bars.Count > 0)
{
    var lastBar = customBars.Bars.LastBar;
    var price = customBars.Symbol.Bid;
    customBars.UpdateLastBar(lastBar.Open, Math.Max(lastBar.High, price), Math.Min(lastBar.Low, price), price, (long)lastBar.TickVolume + 1);
}
```

Python:

```python
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
if customBars.Bars.Count > 0:
    lastBar = customBars.Bars.LastBar
    price = customBars.Symbol.Bid
    customBars.UpdateLastBar(lastBar.Open, max(lastBar.High, price), min(lastBar.Low, price), price, int(lastBar.TickVolume) + 1)
```

