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

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

# TradeType (enum)

The direction of a trade order.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum TradeType
```

## Remarks

Indicates the trade direction, whether it is a Buy or a Sell trade.

## Examples

C#:

```csharp
var tradeType = Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1) ? TradeType.Buy : TradeType.Sell;
var result = ExecuteMarketOrder(tradeType, SymbolName, 10000, "myLabel", 20, 40);
Print("{0} order executed: {1}", tradeType, result.IsSuccessful);
```

Python:

```python
tradeType = TradeType.Buy if api.Bars.ClosePrices.Last(1) > api.Bars.OpenPrices.Last(1) else TradeType.Sell
result = api.ExecuteMarketOrder(tradeType, api.SymbolName, 10000, "myLabel", 20, 40)
api.Print(f"{tradeType} order executed: {result.IsSuccessful}")
```

C#:

```csharp
var position = Positions.Find("myLabel", "EURUSD", TradeType.Sell);
if (position == null)
    PlaceLimitOrder(TradeType.Sell, "EURUSD", 10000, Symbols.GetSymbol("EURUSD").Ask + 0.0020, "myLabel");
```

Python:

```python
position = api.Positions.Find("myLabel", "EURUSD", TradeType.Sell)
if position is None:
    api.PlaceLimitOrder(TradeType.Sell, "EURUSD", 10000, api.Symbols.GetSymbol("EURUSD").Ask + 0.0020, "myLabel")
```

## Values

- `TradeType.Buy` — Represents a Buy order.
- `TradeType.Sell` — Represents a Sell order.

