/// <summary> /// new data came from the connector / /// из коннектора пришли новые данные /// </summary> private void BotTabIndex_NewCandlesChangeEvent(List <Candle> candles) { LastTimeCandleUpdate = DateTime.Now; for (int i = 0; i < Tabs.Count; i++) { List <Candle> myCandles = Tabs[i].Candles(true); if (myCandles == null || myCandles.Count < 10) { return; } } DateTime time = Tabs[0].Candles(true)[Tabs[0].Candles(true).Count - 1].TimeStart; for (int i = 0; i < Tabs.Count; i++) { List <Candle> myCandles = Tabs[i].Candles(true); if (myCandles[myCandles.Count - 1].TimeStart != time) { return; } } //loop to collect all the candles in one array // цикл для сбора всех свечей в один массив if (string.IsNullOrWhiteSpace(ConvertedFormula)) { return; } string nameArray = Calculate(ConvertedFormula); if (_valuesToFormula != null && !string.IsNullOrWhiteSpace(nameArray)) { ValueSave val = _valuesToFormula.Find(v => v.Name == nameArray); if (val != null) { Candles = val.ValueCandles; if (Candles.Count > 1 && Candles[Candles.Count - 1].TimeStart == Candles[Candles.Count - 2].TimeStart) { try { Candles.RemoveAt(Candles.Count - 1); } catch { // ignore } } if (_startProgram == StartProgram.IsOsTrader && Tabs.Count > 0) { var candlesToKeep = ((OsEngine.Market.Servers.AServer)Tabs[0].MyServer)._neadToSaveCandlesCountParam.Value; var needToRemove = ((OsEngine.Market.Servers.AServer)Tabs[0].MyServer)._needToRemoveCandlesFromMemory.Value; if (needToRemove && Candles[Candles.Count - 1].TimeStart.Minute % 15 == 0 && Candles[Candles.Count - 1].TimeStart.Second == 0 && Candles.Count > candlesToKeep) { Candles.RemoveRange(0, Candles.Count - 1 - candlesToKeep); } } _chartMaster.SetCandles(Candles); if (SpreadChangeEvent != null) { SpreadChangeEvent(Candles); } } } }