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:

C#
private void NewStopOrderClick(object sender, RoutedEventArgs e)
{
    var newOrder = new OrderConditionalWindow
    {
        Order = new Order
        {
            Security = SecurityPicker.SelectedSecurity,
            Type = OrderTypes.Conditional,
        },
        SecurityProvider = MainWindow.Instance.Trader,
        MarketDataProvider = MainWindow.Instance.Trader,
        Portfolios = new PortfolioDataSource(MainWindow.Instance.Trader),
        Adapter = MainWindow.Instance.Trader.TransactionAdapter
    };

    if (newOrder.ShowModal(this))
        MainWindow.Instance.Trader.RegisterOrder(newOrder.Order);
}

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.