---
id: "T:cAlgo.API.PositionOpenedEventArgs"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/EventArgs/PositionOpenedEventArgs/"
---

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

# PositionOpenedEventArgs (class)

Provides data for the position opening event.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public class PositionOpenedEventArgs
```

## Examples

C#:

```csharp
public class Test : Robot
{
    protected override void OnStart()
    {
        Positions.Opened += OnPositionOpened;
        ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 10000, "myLabel");
    }
    private void OnPositionOpened(PositionOpenedEventArgs args)
    {
        var position = args.Position;
        if(position.Label == "myLabel")
            Print("Position opened by Test");
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        api.Positions.Opened += self.on_position_opened
        api.ExecuteMarketOrder(TradeType.Buy, api.Symbol.Name, 10000, "myLabel")

    def on_position_opened(self, args):
        position = args.Position
        if position.Label == "myLabel":
            print("Position opened by Test")
```

## Properties

- `public Position Position {get;}` — Gets or sets the position being opened. [details](https://help.ctrader.com/ctrader-algo/references/EventArgs/PositionOpenedEventArgs/Position/index.md)

