Click or drag to resize

Stop orders

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

C#
private void SendClick(object sender, RoutedEventArgs e)
{
    var condType = StopOrderType.GetSelectedValue<BlackwoodOrderConditionTypes>();

    if (condType == null)
    {
        MessageBox.Show(this, "Conditional type must be selected.");
        return;
    }

    var stopOrder = new Order
    {
        Portfolio = Portfolio.SelectedPortfolio,
        Type = OrderTypes.Conditional,
        Security = Security,
        Direction = IsBuy.IsChecked == true ? OrderDirections.Buy : OrderDirections.Sell,
        ExpiryDate = ExpiryDate.Value == null ? (DateTime?) null : ExpiryDate.Value.Value,
        Volume = Volume.Text.To<decimal>(),
        Price = Price.Text.To<decimal>(),
        Condition = new BlackwoodOrderCondition
        {
            Type = condType.Value,
            StopPrice = StopPrice.Text.To<decimal>()
        }
    };

    MainWindow.Instance.Trader.RegisterOrder(stopOrder);
    DialogResult = true;
}

The BlackwoodTrader connector provides the special BlackwoodOrderCondition сlass to work with the stop orders conditions. This class supports the types of stop orders indicated in the BlackwoodOrderConditionTypes.