---
id: "T:cAlgo.API.ProtectionType"
kind: "enum"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/ProtectionType/"
---

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

# ProtectionType (enum)

The protection type for orders and positions.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum ProtectionType
```

Available since cAlgo.API 5.1.

## Examples

C#:

```csharp
var result = PlaceLimitOrder(TradeType.Buy, SymbolName, 10000, Symbol.Bid - 20 * Symbol.PipSize, "myLabel", 20, 40, ProtectionType.Relative);
if (result.IsSuccessful)
    Print("Stop loss {0}, take profit {1}", result.PendingOrder.StopLoss, result.PendingOrder.TakeProfit);
```

Python:

```python
result = api.PlaceLimitOrder(TradeType.Buy, api.SymbolName, 10000, api.Symbol.Bid - 20 * api.Symbol.PipSize, "myLabel", 20, 40, ProtectionType.Relative)
if result.IsSuccessful:
    api.Print(f"Stop loss {result.PendingOrder.StopLoss}, take profit {result.PendingOrder.TakeProfit}")
```

C#:

```csharp
var position = Positions.Find("myLabel");
if (position != null && position.TradeType == TradeType.Buy)
{
    var pipSize = position.Symbol.PipSize;
    ModifyPosition(position, position.EntryPrice - 20 * pipSize, position.EntryPrice + 40 * pipSize, ProtectionType.Absolute);
}
```

Python:

```python
position = api.Positions.Find("myLabel")
if position is not None and position.TradeType == TradeType.Buy:
    pipSize = position.Symbol.PipSize
    api.ModifyPosition(position, position.EntryPrice - 20 * pipSize, position.EntryPrice + 40 * pipSize, ProtectionType.Absolute)
```

## Values

- `ProtectionType.None` — No protection.
- `ProtectionType.Relative` — Relative or distance based protection type.
- `ProtectionType.Absolute` — Absolute or price based protection type.

