Skip to content

Position Property

Summary

Gets the position being closed.

Signature

1
public Position Position {get;}

Return Value

Position

Declaring Type

cAlgo.API.PositionClosedEventArgs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 protected override void OnStart()
 {
     ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "myLabel");
     Positions.Closed += PositionsClosed;
 }
 private void PositionsClosed(PositionClosedEventArgs args)
 {
     var position = args.Position;
     if(position.Label == "myLabel")
     {
         var tradeType = position.TradeType;
         var symbol = MarketData.GetSymbol(position.SymbolCode);
         var volume = position.Volume;
         var label = position.Label;
         if(position.GrossProfit > 0)
             ExecuteMarketOrder(tradeType, symbol, volume, label);
         else
         {
             var oppositeTrade = tradeType == TradeType.Buy
                         ? TradeType.Sell
                         : TradeType.Buy;
             ExecuteMarketOrder(oppositeTrade, symbol, volume, label);
         }
     }
 }

Last update: December 5, 2022

Comments