---
id: "T:cAlgo.API.Position"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/"
---

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

# Position (interface)

Taking or opening a position means buying or selling a trading pair.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface Position
```

## Examples

C#:

```csharp
foreach (var position in Positions)
{
    Print("Position {0} {1} {2}: entry {3}, net profit {4}", position.Id, position.SymbolName, position.TradeType, position.EntryPrice, position.NetProfit);
}
```

Python:

```python
for position in api.Positions:
    api.Print(f"Position {position.Id} {position.SymbolName} {position.TradeType}: entry {position.EntryPrice}, net profit {position.NetProfit}")
```

C#:

```csharp
var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.QuantityToVolumeInUnits(0.01), "myLabel", 20, 40);
if (result.IsSuccessful)
{
    var position = result.Position;
    position.ModifyStopLossPips(10);
    position.Close();
}
else
{
    Print("Order failed: {0}", result.Error);
}
```

Python:

```python
result = api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.QuantityToVolumeInUnits(0.01), "myLabel", 20, 40)
if result.IsSuccessful:
    position = result.Position
    position.ModifyStopLossPips(10)
    position.Close()
else:
    api.Print(f"Order failed: {result.Error}")
```

C#:

```csharp
protected override void OnStart()
{
    Positions.Opened += OnPositionsOpened;
    Positions.Closed += OnPositionsClosed;
}

private void OnPositionsOpened(PositionOpenedEventArgs args)
{
    Print("Position {0} opened at {1}", args.Position.Id, args.Position.EntryPrice);
}

private void OnPositionsClosed(PositionClosedEventArgs args)
{
    Print("Position {0} closed ({1}), net profit {2}", args.Position.Id, args.Reason, args.Position.NetProfit);
}
```

Python:

```python
def on_start(self):
    api.Positions.Opened += self.on_positions_opened
    api.Positions.Closed += self.on_positions_closed

def on_positions_opened(self, args):
    api.Print(f"Position {args.Position.Id} opened at {args.Position.EntryPrice}")

def on_positions_closed(self, args):
    api.Print(f"Position {args.Position.Id} closed ({args.Reason}), net profit {args.Position.NetProfit}")
```

## Methods

- `TradeResult Close()` — Shortcut for the Robot.ClosePosition method. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Close/index.md)
- `TradeResult ModifyStopLossBreakEven(StopLossBreakEven stopLossBreakEven)` — Shortcut for the Robot.ModifyPosition method to change the StopLoss Break-Even. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyStopLossBreakEven/index.md)
- `TradeResult ModifyStopLossPips(double? stopLossPips)` — Shortcut for the Robot.ModifyPosition method to change the Stop Loss pips [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyStopLossPips/index.md)
- `TradeResult ModifyStopLossPrice(double? stopLoss)` — Shortcut for Robot.ModifyPosition method to change the Stop Loss. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyStopLossPrice/index.md)
- `TradeResult ModifyTakeProfit(RelativeTakeProfitProtections takeProfitProtections)` — Shortcut for the Robot.ModifyPosition method to change the Take Profit protection [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyTakeProfit/index.md)
- `TradeResult ModifyTakeProfit(AbsoluteTakeProfitProtections takeProfitProtections)` — Shortcut for the Robot.ModifyPosition method to change the Take Profit protection [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyTakeProfit/index.md)
- `TradeResult ModifyTakeProfitPips(double? takeProfitPips)` — Shortcut for the Robot.ModifyPosition method to change the Take Profit pips [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyTakeProfitPips/index.md)
- `TradeResult ModifyTakeProfitPrice(double? takeProfit)` — Shortcut for Robot.ModifyPosition method to change the Take Profit. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyTakeProfitPrice/index.md)
- `TradeResult ModifyTrailingStop(bool hasTrailingStop)` — Shortcut for the Robot.ModifyPosition method to change the Trailing Stop. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyTrailingStop/index.md)
- `TradeResult ModifyVolume(double volume)` — Shortcut for the Robot.ModifyPosition method to change the VolumeInUnits. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/ModifyVolume/index.md)
- `TradeResult Reverse()` — Shortcut for the Robot.ReversePosition method to change the direction of the trade. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Reverse/index.md)
- `TradeResult Reverse(double volume)` — Shortcut for the Robot.ReversePosition method to change the direction of trade and the volume. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Reverse/index.md)

## Properties

- `AbsoluteTakeProfitProtections AbsoluteTakeProfitProtections {get;}` — The take profit protections of the position. Null if position has no take profit. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/AbsoluteTakeProfitProtections/index.md)
- `string Channel {get;}` — Gets the channel via which the position was placed in a string format. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Channel/index.md)
- `string Comment {get;}` — Comment can be used as a note for the order. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Comment/index.md)
- `double Commissions {get;}` — Commission Amount of the request to trade one way (Buy/Sell) associated with this position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Commissions/index.md)
- `double CurrentPrice {get;}` — Gets the position current market price. If Position's TradeType is Buy it returns Symbol current Bid price. If position's TradeType is Sell it returns Symbol current Ask price. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/CurrentPrice/index.md)
- `IReadonlyList<Deal> Deals {get;}` — Gets the position deals. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Deals/index.md)
- `double EntryPrice {get;}` — Entry price of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/EntryPrice/index.md)
- `DateTime EntryTime {get;}` — Entry time of trade associated with the position. The Timezone used is set in the cBot attribute. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/EntryTime/index.md)
- `double GrossProfit {get;}` — Gross profit accrued by the order associated with the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/GrossProfit/index.md)
- `bool HasTrailingStop {get;}` — When HasTrailingStop set to true, the server updates the Stop Loss every time the position moves in your favor. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/HasTrailingStop/index.md)
- `int Id {get;}` — The position's unique identifier. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Id/index.md)
- `string Label {get;}` — Label can be used to represent the order. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Label/index.md)
- `DateTime? LastUpdateTime {get;}` — Gets the time when a position was last updated. The timezone used is set in the algorithm class attribute. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/LastUpdateTime/index.md)
- `double Margin {get;}` — The amount of used margin by the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Margin/index.md)
- `double NetProfit {get;}` — The Net profit of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/NetProfit/index.md)
- `double Pips {get;}` — Represents the winning or loosing pips of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Pips/index.md)
- `double Quantity {get;}` — Quantity of lots traded by the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Quantity/index.md)
- `double? StopLoss {get;}` — The Stop Loss level of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/StopLoss/index.md)
- `StopLossBreakEven StopLossBreakEven {get;}` — The stop loss break even of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/StopLossBreakEven/index.md)
- `StopTriggerMethod? StopLossTriggerMethod {get;}` — Trigger method for the position's Stop Loss. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/StopLossTriggerMethod/index.md)
- `double Swap {get;}` — Swap is the overnight interest rate if any, accrued on the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Swap/index.md)
- `Symbol Symbol {get;}` — Gets the position symbol. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/Symbol/index.md)
- `string SymbolName {get;}` — Gets the symbol name. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/SymbolName/index.md)
- `double? TakeProfit {get;}` — The take profit level of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/TakeProfit/index.md)
- `TradeType TradeType {get;}` — Trade type (Buy/Sell) of the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/TradeType/index.md)
- `double VolumeInUnits {get;}` — The amount traded by the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/VolumeInUnits/index.md)

## Deprecated members

- `string SymbolCode {get;}` — Use SymbolName instead
- `long Volume {get;}` — Use VolumeInUnits instead
- `decimal Profit {get;}` — Use GrossProfit instead

