---
id: "P:cAlgo.API.HistoricalOrder.PositionId"
kind: "property"
type: "T:cAlgo.API.HistoricalOrder"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/HistoricalOrders/HistoricalOrder/PositionId/"
---

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

# HistoricalOrder.PositionId

Member of [HistoricalOrder](https://help.ctrader.com/ctrader-algo/references/Trading/HistoricalOrders/HistoricalOrder/index.md).

## PositionId

Unique position Id.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
int? PositionId {get;}
```

Python:

```python
historicalOrder.PositionId: int | None
```

### Returns

`int?` — 

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
var order = HistoricalOrders.FindLast("myLabel");
if (order != null && order.PositionId.HasValue)
    Print("Order opened or modified position {0}", order.PositionId.Value);
```

Python:

```python
order = api.HistoricalOrders.FindLast("myLabel")
if order is not None and order.PositionId is not None:
    api.Print(f"Order opened or modified position {order.PositionId}")
```

