Bottom Axis without weekends, but with null data
Posted: Wed Oct 29, 2008 10:32 am
Hello,
I have a problem with Candle Series and maybe some other. I want to display OHLC chart with some upper indicators (moving average, bollinger...) and some indicators below (like volume, MACD OBV, some custom functions...). They all share the same horizontal axis and it is not problem if I take only valid data into Series (like no weekends example).
But, if I want to display all datetime intervals, even with no data, I have a problem.
For example, in the following code, Candle is wrong (data for non-existing days must not be shown or can be shown as some 'x' mark), and Volume is ok (not shown).
Is there any workaround or maybe I'm doing something wrong?
Goran
I have a problem with Candle Series and maybe some other. I want to display OHLC chart with some upper indicators (moving average, bollinger...) and some indicators below (like volume, MACD OBV, some custom functions...). They all share the same horizontal axis and it is not problem if I take only valid data into Series (like no weekends example).
But, if I want to display all datetime intervals, even with no data, I have a problem.
For example, in the following code, Candle is wrong (data for non-existing days must not be shown or can be shown as some 'x' mark), and Volume is ok (not shown).
Code: Select all
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Date", typeof(DateTime));
dataTable.Columns.Add("Open", typeof(double));
dataTable.Columns.Add("High", typeof(double));
dataTable.Columns.Add("Low", typeof(double));
dataTable.Columns.Add("Close", typeof(double));
dataTable.Columns.Add("Volume", typeof(double));
dataTable.Rows.Add(DateTime.Now.Date.AddDays(-9), 10, 12, 9, 11, 2);
dataTable.Rows.Add(DateTime.Now.Date.AddDays(-8), 10, 12, 9, 11, 3);
dataTable.Rows.Add(DateTime.Now.Date.AddDays(-1), 10, 12, 9, 11, 4);
dataTable.Rows.Add(DateTime.Now.Date, 10, 12, 9, 11, 5);
Candle candleSeries1 = new Candle(tChart1);
candleSeries1.XValues.DateTime = false;
Volume volumeSeries1 = new Volume(tChart1);
Steema.TeeChart.Styles.StringList labels = new Steema.TeeChart.Styles.StringList();
DateTime dateFrom = DateTime.Date.Now.AddDays(-10);
DateTime dateTo = DateTime.Date.Now;
TimeSpan ts = dateTo - dateFrom;
int dataCount = 0;
int j = 0;
for (int i = 0; i <= ts.Days; i++)
{
DateTime dataDay = dateFrom.Date.AddDays(i);
if (dataDay.DayOfWeek != DayOfWeek.Saturday && dataDay.DayOfWeek != DayOfWeek.Sunday)
{
if (dataTable.Rows.Count > j)
{
DataRow row = dataTable.Rows[j];
DateTime dayTemp = (DateTime)row["Date"];
if (dataDay == dayTemp)
{
candleSeries1.Add(dataCount,
(double)row["Open"],
(double)row["High"],
(double)row["Low"],
(double)row["Close"]);
volumeSeries1.Add(dataCount, (double)row["Volume"]);
j++;
}
else // add empty data
{
candleSeries1.Add();
volumeSeries1.Add();
}
labels.Add(dataDay.ToShortDateString());
}
dataCount++;
}
}
candleSeries1.Labels = labels;
Goran