Click or drag to resize

Stop orders

The same RegisterOrder method is used to register stop orders, but with stop condition OpenECryOrderCondition and the Conditional type of order indicating:

private void Send_Click(object sender, RoutedEventArgs e)
    var stopOrder = new Order
        Portfolio = Portfolio.SelectedPortfolio,
        Type = OrderTypes.Conditional,
        Volume = Volume.Text.To<decimal>(),
        Price = Price.Text.To<decimal>(),
        Security = Security,
        Direction = IsBuy.IsChecked == true ? OrderDirections.Buy : OrderDirections.Sell,
        ExpiryDate = IsOneDay.IsChecked == true ? DateTime.Today : DateTime.MaxValue,
        StopCondition = new OECOrderCondition(StopMarket ? OECStopType.StopMarket : OECStopType.StopLimit, StopPrice.Text.To<decimal>())

    DialogResult = true;

The OpenECryTrader adapter provides the special OpenECryOrderCondition сlass to work with the stop orders conditions. This class supports the following types of stop orders:

  • StopMarket – a market order is automatically executed after the stop price is reached.

  • StopLimit – a limit order is automatically executed after the stop price is reached.

  • TrailingStopMarket – stop price automatically follows the market, but only in a favorable direction for the position, remaining the stated-in-advance distancefrom market price. If the market reaches the stop price, market order is automatically executed.

  • TrailingStopLimit – same as TrailingStopMarket, but when stop price is reached the limit order is registered.