/// <summary> /// Инициализация панели с контроля сделки /// </summary> private void InitPanelControl() { numericUpDownMCPriceLastTrade.InitSecurity(Securities); numericUpDownMCStopTiks.InitWheelDecimal(0, 1000, 1, 0); numericUpDownMCTakeProfitTiks.InitWheelDecimal(0, 1000, 1, 0); //Получаем сохраненные данные numericUpDownMCStopTiks.Value = SettingsDepth.Get("TiksControlStop"); numericUpDownMCTakeProfitTiks.Value = SettingsDepth.Get("TiksControlTake"); numericUpDownMCStopTiks.ValueChanged += (s, e) => { SettingsDepth.Set("TiksControlStop", (int)numericUpDownMCStopTiks.Value); }; numericUpDownMCTakeProfitTiks.ValueChanged += (s, e) => { SettingsDepth.Set("TiksControlTake", (int)numericUpDownMCTakeProfitTiks.Value); }; //ВЫставляем флажок на сохраненном проценте foreach (var percent in PERCENT) { var objRadio = GetRadioButtonByPercent(percent); if (objRadio.NotIsNull()) { if (percent == SettingsDepth.Get("PercentTakeOut")) { objRadio.Checked = true; } objRadio.CheckedChanged += (s, e) => { SettingsDepth.Set("PercentTakeOut", percent); }; } } buttonMCClose.Click += (s, e) => { var sOrders = GetStopOrdersForControl(); foreach (var sOrd in sOrders) { Trader.CancelStopOrder(sOrd); } }; buttonMCReset.Click += (s, e) => { LoopControl(true); }; buttonACPriceUp.Click += (s, e) => { numericUpDownMCStopTiks.Value++; numericUpDownMCTakeProfitTiks.Value = numericUpDownMCTakeProfitTiks.Value > 0 ? numericUpDownMCTakeProfitTiks.Value - 1 : 0; }; buttonACPriceDown.Click += (s, e) => { numericUpDownMCStopTiks.Value = numericUpDownMCStopTiks.Value > 0 ? numericUpDownMCStopTiks.Value - 1 : 0; numericUpDownMCTakeProfitTiks.Value++; }; }
/// <summary> Инициализация нового инструмента в текущем окне. Сброс на новый инструмент.</summary> private void InitReset() { this.SetHead(Securities); //Загружаем настройки по инструменту //SettingsDepth.ReloadSecurity(Securities.ToString()); SettingsDepth.InitTimeFrame(StorageTimeFrames.TIME_FRAMES); //Инициализация всех панелей InitAllPanels(); //Регистрация стакана Trader.RegisterDepth(Securities); //цена для заявки numericUpDownPrice.InitSecurity(Securities); numericUpDownPrice.Value = 0; //Стоп цена numericUpDownStopPrice.InitSecurity(Securities); numericUpDownStopPrice.Value = 0; //Дата эксписрациия стоп заявки dateTimePickerStopOrder.Value = DateTime.Now.AddDays(SettingsDepth.Get("CountDaysForStopOrder")); //Получаем значение последней стоп-заявки if (LastStopOrder.NotIsNull()) { numericUpDownStopPrice.Value = LastStopOrder.ConditionPrice; dateTimePickerStopOrder.Value = DateTime.Now.AddDays(SettingsDepth.Get("CountDaysForStopOrder")); } //Настройки графика this.GraphicStock = new Graphic(); this.GraphicStock.InitEvents(); this.GraphicStock.SetObjectPaint(this.pictureBoxGraphic); this.GraphicStock.Init(Securities); this.GraphicStock.TimeFrame = CurrentTimeFrame; this.GraphicStock.DataSourceLevels = this.Levels.ObjectCollection; this.GraphicStock.ResetActiveCandles(); GraphicStock.OnNotFullGraphic += (curValue, all) => { if (all - curValue > 5) { CurrentTimeFrame.Candles.Load(); } }; UpdateGraphic(); InitGraphicSignals(); this.GraphicStock.Levels.OnNewLevel += (newLevel) => { this.Levels.Add(newLevel); this.UpdatePanelLevels(); }; this.GraphicStock.OnCandleLeftMouseUp += (point, candle) => { ResetButtonLevels(); }; //Скрол для графика hScrollGraphic.Value = hScrollGraphic.Maximum; //Clear depth dataGridViewDepth.Rows.Clear(); this.ArraySell = null; this.ArrayBuy = null; EventAnyOrder(null, true); pictureBoxGraphic.Refresh(); }