readonly TimeSpan _timeFrame = TimeSpan.FromMinutes(5);
string[] lines = File.ReadAllLines(@"C:\Users\user\Desktop\Торговля\Data\ROSN.csv");
List<Candle> candles = new List<Candle>();
foreach (string line in lines)
{
var parts = line.Split(',');
var time = (parts[0] + parts[1]).ToDateTime("yyyy/MM/ddHH:mm");
if (time < DateTime.Today)
{
candles.Add(new TimeFrameCandle
{
OpenPrice = decimal.Parse(parts[2], CultureInfo.InvariantCulture),
HighPrice = decimal.Parse(parts[3], CultureInfo.InvariantCulture),
LowPrice = decimal.Parse(parts[4], CultureInfo.InvariantCulture),
ClosePrice = decimal.Parse(parts[5], CultureInfo.InvariantCulture),
TimeFrame = _timeFrame,
OpenTime = time,
CloseTime = time + _timeFrame,
TotalVolume = decimal.Parse(parts[6], CultureInfo.InvariantCulture),
Security = _instr1,
State = CandleStates.Finished
});
}
}
int count = candles.Count<Candle>();
int firstElement = 100; // вывод количества свечей из истории
_candleManager.Start(_series);
for (int bar = count - firstElement; bar <= count - 1; bar++)
{
ProcessCandle(_series, candles.ElementAt(bar));
}
...
private void ProcessCandle(CandleSeries series, Candle candle)
{
//_chart.ProcessCandle(_candlesElem, candle);
_chart.ProcessValues(candle.OpenTime, new Dictionary<IChartElement, object>
{
{ _candlesElem, candle },
//{ _longMaElem, longValue },
//{ _shortMaElem, shortValue },
});
}