Skip to content

PositionOpenedEventArgs

class cAlgo.API

DesktopCLICloud

Provides data for the position opening event.

Definition

public class PositionOpenedEventArgs

Namespace: cAlgo.API · Group: EventArgs

Examples

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");
    }
}
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

Name Description
PositionDesktopCLICloudPosition Gets or sets the position being opened.

See also