Position


Summary

Gets the position being closed.

Syntax

public Position Position{ get; }

Example 1

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