public List <Candle> GetSmartComCandleHistory(string security, TimeSpan timeSpan, int count) { if (timeSpan.TotalMinutes > 60 || timeSpan.TotalMinutes < 1) { return(null); } try { StBarInterval tf = StBarInterval.StBarInterval_Quarter; if (Convert.ToInt32(timeSpan.TotalMinutes) == 1) { tf = StBarInterval.StBarInterval_1Min; } else if (Convert.ToInt32(timeSpan.TotalMinutes) == 5) { tf = StBarInterval.StBarInterval_5Min; } else if (Convert.ToInt32(timeSpan.TotalMinutes) == 10) { tf = StBarInterval.StBarInterval_10Min; } else if (Convert.ToInt32(timeSpan.TotalMinutes) == 15) { tf = StBarInterval.StBarInterval_15Min; } else if (Convert.ToInt32(timeSpan.TotalMinutes) == 30) { tf = StBarInterval.StBarInterval_30Min; } else if (Convert.ToInt32(timeSpan.TotalMinutes) == 60) { tf = StBarInterval.StBarInterval_60Min; } if (tf == StBarInterval.StBarInterval_Quarter) { return(null); } _candles = null; while (_candles == null) { lock (_smartComServerLocker) { SmartServer.GetBars(security, tf, DateTime.Now.AddHours(6), count); } } return(_candles); } catch { return(null); } }
/// <summary> /// Метод получает данные с рынка /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { //сбрасываем коллекции к начальному значению ind = nBars; SmartCom.AddBar -= AddBars; BarsList.Clear(); TradesList.Clear(); ClearSeriesMethod(chart1); ClearMethod(chart1.Series); ClearMethod(chart2.Series); chart1.ChartAreas[0].AxisY.Minimum = 0; //получаем бары try { SmartCom.GetBars(symbol, interval, new DateTime(SetDateTime(interval, n).Year, SetDateTime(interval, n).Month, SetDateTime(interval, n).Day, SetDateTime(interval, n).Hour, SetDateTime(interval, n).Minute, SetDateTime(interval, n).Second), -n); SmartCom.AddBar += AddBars; } catch { label3.Text = $"[{DateTime.Now}]: Возникла ошибка!"; } }