---
id: "M:cAlgo.API.Indicator.ModifyPosition(cAlgo.API.Position,System.Double)"
kind: "method"
type: "T:cAlgo.API.Indicator"
url: "https://help.ctrader.com/ctrader-algo/references/General/Indicator/ModifyPosition/"
---

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

# Indicator.ModifyPosition

Member of [Indicator](https://help.ctrader.com/ctrader-algo/references/General/Indicator/index.md).

## ModifyPosition(Position position, double volume)

Modify the volume of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, double volume)
```

Python:

```python
api.ModifyPosition(position: Position, volume: float) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `volume` (`double`, Python `float`): Volume (in units) of Trade

### Returns

`TradeResult` — Trade Result

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

## ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`double?`, Python `float | None`): New stop loss
- `takeProfit` (`double?`, Python `float | None`): New take profit
- `protectionType` (`ProtectionType?`, Python `ProtectionType | None`): Protection type

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)))
```

C#:

```csharp
ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative)
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)))
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)))
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)))
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), StopLossBreakEven(15, 3))
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)))
```

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), StopLossBreakEven(15, 3))
```

## ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None, hasTrailingStop: bool) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`double?`, Python `float | None`): New stop loss
- `takeProfit` (`double?`, Python `float | None`): New take profit
- `protectionType` (`ProtectionType?`, Python `ProtectionType | None`): Protection type
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative, true);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative, True)
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)))
```

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true);
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True)
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10000);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10000)
```

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)))
```

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true);
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True)
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopLossBreakEven(15, 3))
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopLossBreakEven(15, 3))
```

## ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, double? stopLoss, double? takeProfit, ProtectionType? protectionType, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: float | None, takeProfit: float | None, protectionType: ProtectionType | None, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`double?`, Python `float | None`): New stop loss
- `takeProfit` (`double?`, Python `float | None`): New take profit
- `protectionType` (`ProtectionType?`, Python `ProtectionType | None`): Protection type
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], 10, 20, ProtectionType.Relative, true, StopTriggerMethod.Trade);
```

Python:

```python
api.ModifyPosition(api.Positions[0], 10, 20, ProtectionType.Relative, True, StopTriggerMethod.Trade)
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade);
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade)
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade);
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade)
```

## ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade, new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade, StopLossBreakEven(15, 3))
```

## ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)

Modify the protection of a position

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public TradeResult ModifyPosition(Position position, AbsoluteStopLossProtection stopLoss, AbsoluteTakeProfitProtections takeProfits, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven)
```

Python:

```python
api.ModifyPosition(position: Position, stopLoss: AbsoluteStopLossProtection, takeProfits: AbsoluteTakeProfitProtections, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, stopLossBreakEven: StopLossBreakEven) -> TradeResult
```

### Parameters

- `position` (`Position`, Python `Position`): Position which is affected
- `stopLoss` (`AbsoluteStopLossProtection`, Python `AbsoluteStopLossProtection`): Absolute Stop loss
- `takeProfits` (`AbsoluteTakeProfitProtections`, Python `AbsoluteTakeProfitProtections`): Absolute Take profits
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss

### Returns

`TradeResult` — Trade Result

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ModifyPosition(Positions[0], new AbsoluteStopLossProtection(10), new AbsoluteTakeProfitProtections(new AbsoluteTakeProfitProtection(1000, 10), new AbsoluteTakeProfitProtection(2000, 20), new AbsoluteTakeProfitLastProtection(30)), true, StopTriggerMethod.Trade, new StopLossBreakEven(15, 3));
```

Python:

```python
api.ModifyPosition(api.Positions[0], AbsoluteStopLossProtection(10), AbsoluteTakeProfitProtections(AbsoluteTakeProfitProtection(1000, 10), AbsoluteTakeProfitProtection(2000, 20), AbsoluteTakeProfitLastProtection(30)), True, StopTriggerMethod.Trade, StopLossBreakEven(15, 3))
```

