---
id: "M:cAlgo.API.Plugin.ExecuteMarketOrderAsync(cAlgo.API.TradeType,System.String,System.Double,System.Action{cAlgo.API.TradeResult})"
kind: "method"
type: "T:cAlgo.API.Plugin"
url: "https://help.ctrader.com/ctrader-algo/references/General/Plugin/ExecuteMarketOrderAsync/"
---

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

# Plugin.ExecuteMarketOrderAsync

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

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLossPips: float | None, takeProfitPips: float | None, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLossPips` (`double?`, Python `float | None`): Stop loss in pips
- `takeProfitPips` (`double?`, Python `float | None`): Take profit in pips
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLossPips: float | None, takeProfitPips: float | None, comment: str, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLossPips` (`double?`, Python `float | None`): Stop loss in pips
- `takeProfitPips` (`double?`, Python `float | None`): Take profit in pips
- `comment` (`string`, Python `str`): Order comment
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, bool hasTrailingStop, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, bool hasTrailingStop, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLossPips: float | None, takeProfitPips: float | None, comment: str, hasTrailingStop: bool, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLossPips` (`double?`, Python `float | None`): Stop loss in pips
- `takeProfitPips` (`double?`, Python `float | None`): Take profit in pips
- `comment` (`string`, Python `str`): Order comment
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", true, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", True, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, double? stopLossPips, double? takeProfitPips, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLossPips: float | None, takeProfitPips: float | None, comment: str, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLossPips` (`double?`, Python `float | None`): Stop loss in pips
- `takeProfitPips` (`double?`, Python `float | None`): Take profit in pips
- `comment` (`string`, Python `str`): Order comment
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", true, StopTriggerMethod.Trade, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", 10, 20, "order comment", True, StopTriggerMethod.Trade, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossTriggerMethod` (`StopTriggerMethod?`, Python `StopTriggerMethod | None`): Trigger method for position's StopLoss
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", true, StopTriggerMethod.Trade, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", True, StopTriggerMethod.Trade, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, hasTrailingStop: bool, stopLossTriggerMethod: StopTriggerMethod | None, stopLossBreakEven: StopLossBreakEven, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `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
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", true, StopTriggerMethod.Trade, new StopLossBreakEven(15, 3), result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", True, StopTriggerMethod.Trade, StopLossBreakEven(15, 3), lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, stopLossBreakEven: StopLossBreakEven, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), new StopLossBreakEven(15, 3), result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), StopLossBreakEven(15, 3), lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, stopLossBreakEven: StopLossBreakEven, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", new StopLossBreakEven(15, 3), result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", StopLossBreakEven(15, 3), lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, hasTrailingStop: bool, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", true, result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", True, lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

## ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)

Execute a market order in asynchronous execution mode

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
public TradeOperation ExecuteMarketOrderAsync(TradeType tradeType, string symbolName, double volume, string label, RelativeStopLossProtection stopLoss, RelativeTakeProfitProtections takeProfits, string comment, bool hasTrailingStop, StopLossBreakEven stopLossBreakEven, Action<TradeResult> callback)
```

Python:

```python
api.ExecuteMarketOrderAsync(tradeType: TradeType, symbolName: str, volume: float, label: str, stopLoss: RelativeStopLossProtection, takeProfits: RelativeTakeProfitProtections, comment: str, hasTrailingStop: bool, stopLossBreakEven: StopLossBreakEven, callback: Callable[[TradeResult], None]) -> TradeOperation
```

### Parameters

- `tradeType` (`TradeType`, Python `TradeType`): Direction of trade
- `symbolName` (`string`, Python `str`): Symbol name of trade
- `volume` (`double`, Python `float`): Volume (in units) of trade
- `label` (`string`, Python `str`): Label representing the order
- `stopLoss` (`RelativeStopLossProtection`, Python `RelativeStopLossProtection`): Relative Stop loss
- `takeProfits` (`RelativeTakeProfitProtections`, Python `RelativeTakeProfitProtections`): Relative Take profits
- `comment` (`string`, Python `str`): Order comment
- `hasTrailingStop` (`bool`, Python `bool`): Enable/disable TrailingStop for position
- `stopLossBreakEven` (`StopLossBreakEven`, Python `StopLossBreakEven`): Break-even for position's StopLoss
- `callback` (`Action<TradeResult>`, Python `Callable[[TradeResult], None]`): Event raised when position is opened

### Returns

`TradeOperation` — Trade Operation

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", new RelativeStopLossProtection(10), new RelativeTakeProfitProtections(new RelativeTakeProfitProtection(1000, 10), new RelativeTakeProfitProtection(2000, 20), new RelativeTakeProfitLastProtection(30)), "order comment", true, new StopLossBreakEven(15, 3), result => Print("Trade result: {0}", result.IsSuccessful));
```

Python:

```python
api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000, "myLabel", RelativeStopLossProtection(10), RelativeTakeProfitProtections(RelativeTakeProfitProtection(1000, 10), RelativeTakeProfitProtection(2000, 20), RelativeTakeProfitLastProtection(30)), "order comment", True, StopLossBreakEven(15, 3), lambda result: api.Print(f"Trade result: {result.IsSuccessful}"))
```

