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

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

# ErrorCode (enum)

Enumeration of standard error codes.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum ErrorCode
```

## Remarks

Error codes are readable descriptions of the responses returned by the server.

## Examples

C#:

```csharp
var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "myLabel", 20, 40);
if (!result.IsSuccessful)
{
    switch (result.Error)
    {
        case ErrorCode.NoMoney:
            Print("Not enough money to open the position");
            break;
        case ErrorCode.MarketClosed:
            Print("The market is closed");
            break;
        default:
            Print("Order failed: {0}", result.Error);
            break;
    }
}
```

Python:

```python
result = api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, 10000, "myLabel", 20, 40)
if not result.IsSuccessful:
    if result.Error == ErrorCode.NoMoney:
        api.Print("Not enough money to open the position")
    elif result.Error == ErrorCode.MarketClosed:
        api.Print("The market is closed")
    else:
        api.Print(f"Order failed: {result.Error}")
```

C#:

```csharp
protected override void OnError(Error error)
{
    if (error.Code == ErrorCode.BadVolume)
        Print("Bad volume");
    else if (error.Code == ErrorCode.Disconnected)
        Print("Disconnected");
    else
        Print("Error: {0}", error.Code);
}
```

Python:

```python
def on_error(self, error):
    if error.Code == ErrorCode.BadVolume:
        api.Print("Bad volume")
    elif error.Code == ErrorCode.Disconnected:
        api.Print("Disconnected")
    else:
        api.Print(f"Error: {error.Code}")
```

## Values

- `ErrorCode.TechnicalError` — A generic technical error with a trade request.
- `ErrorCode.BadVolume` — The volume value is not valid
- `ErrorCode.NoMoney` — There are not enough money in the account to trade with.
- `ErrorCode.MarketClosed` — The market is closed.
- `ErrorCode.Disconnected` — The server is disconnected.
- `ErrorCode.EntityNotFound` — Position does not exist.
- `ErrorCode.Timeout` — Operation timed out.
- `ErrorCode.UnknownSymbol` — Unknown symbol.
- `ErrorCode.InvalidStopLossTakeProfit` — The invalid Stop Loss or Take Profit.
- `ErrorCode.InvalidRequest` — The invalid request.
- `ErrorCode.NoTradingPermission` — Occurs when accessing trading API without trading permission.

