Пример #1
0
        private void ShowOrderParams()
        {
            // заголовок окна
            Text = order.ToString();

            // параметры сделки
            cbStatus.SelectedIndex = cbStatus.Items.IndexOf(EnumFriendlyName <PositionState> .GetString(order.State));
            if (order.State == PositionState.Closed)
            {
                cbExitReason.SelectedIndex = cbExitReason.Items.IndexOf(EnumFriendlyName <PositionExitReason> .GetString(order.ExitReason));
            }
            else
            {
                cbExitReason.Visible = false;
            }

            tbPriceEnter.Text = FormatPrice(order.PriceEnter);
            dpEnter.Value     = order.TimeEnter;
            if (order.PriceExit.HasValue)
            {
                tbPriceExit.Text = FormatPrice(order.PriceExit.Value);
            }
            if (order.TimeExit.HasValue)
            {
                dpExit.Value = order.TimeExit.Value;
            }
            if (order.StopLoss.HasValue && order.StopLoss.Value > 0)
            {
                tbSL.Text = FormatPrice(order.StopLoss.Value);
            }
            if (order.TakeProfit.HasValue && order.TakeProfit.Value > 0)
            {
                tbTP.Text = FormatPrice(order.TakeProfit.Value);
            }
            if (order.Magic.HasValue)
            {
                tbMagic.Text = order.Magic.Value.ToString();
            }
            tbVolume.Text = order.Volume.ToStringUniformMoneyFormat();

            var sbTrailing = new StringBuilder();

            for (var i = 0; i < order.trailingLevels.Length; i++)
            {
                if ((!order.trailingLevels[i].HasValue) || order.trailingLevels[i] == 0 ||
                    (!order.trailingTargets[i].HasValue))
                {
                    break;
                }
                sbTrailing.AppendFormat("[{0} - {1}]",
                                        FormatPrice(order.trailingLevels[i].Value),
                                        FormatPrice(order.trailingTargets[i].Value));
            }
            tbTrailing.Text = sbTrailing.ToString();
            tbComment.Text  =
                string.IsNullOrEmpty(order.Comment) && string.IsNullOrEmpty(order.ExpertComment) ? ""
                : string.IsNullOrEmpty(order.Comment) ? "[R] " + order.ExpertComment
                : string.IsNullOrEmpty(order.ExpertComment) ? order.Comment
                : order.Comment + ", [R] " + order.ExpertComment;
        }
 /// <summary>
 /// Methord Fired when Market Order Arrives.
 /// </summary>
 /// <param name="obj"></param>
 private void MarketOrderArrived(MarketOrder obj)
 {
     try
     {
         if (Logger.IsInfoEnabled)
         {
             Logger.Info(obj.ToString(), _type.FullName, "MarketOrderArrived");
         }
         _simulateMarketOrder.NewMarketOrderArrived(obj);
     }
     catch (Exception exception)
     {
         Logger.Error(exception, _type.FullName, "MarketOrderArrived");
     }
 }