Skip to content

PositionOpenedEventArgs

Summary

Provides data for the position opening event.

Signature

1
public class PositionOpenedEventArgs

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 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");
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 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")

See Also

Properties

Position

Summary

Gets or sets the position being opened.

Signature

1
public Position Position {get;}

Return Value

Position

Examples

1
2
3
4
5
 private void PositionsOnOpened(PositionOpenedEventArgs args)
 {
     var position = args.Position;
     Print("Position opened at {0}", position.EntryPrice);
 }