private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, (int)count); m_Stock.XValues.Clear(); DateTime dtNow = dtStart; for (int i = 0; i < m_Stock.Values.Count; i++) { m_Stock.XValues.Add(dtNow.ToOADate()); dtNow = span.Add(dtNow); } }
void GenerateData() { // generate data for 30 weeks DateTime dtNow = DateTime.Now; DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); DateTime dtStart = NDateTimeUnit.Week.Add(dtEnd, -30); NDateTimeSpan span = new NDateTimeSpan(1, NDateTimeUnit.Day); long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); double open, high, low, close; m_Stock.DataPoints.Clear(); Random random = new Random(); double prevClose = 100; for (int nIndex = 0; nIndex < count; nIndex++) { open = prevClose; if (prevClose < 25 || random.NextDouble() > 0.5) { // upward price change close = open + (2 + (random.NextDouble() * 20)); high = close + (random.NextDouble() * 10); low = open - (random.NextDouble() * 10); } else { // downward price change close = open - (2 + (random.NextDouble() * 20)); high = open + (random.NextDouble() * 10); low = close - (random.NextDouble() * 10); } if (low < 1) { low = 1; } prevClose = close; m_Stock.DataPoints.Add(new NStockDataPoint(NDateTimeHelpers.ToOADate(dtNow), open, close, high, low)); dtNow = span.Add(dtNow); } }
private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, (int)count); m_Stock.XValues.Clear(); DateTime dtNow = dtStart; for (int i = 0; i < m_Stock.Values.Count; i++) { m_Stock.XValues.Add(dtNow.ToOADate()); dtNow = span.Add(dtNow); } m_Chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false; }
private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); double open, high, low, close; m_Stock.DataPoints.Clear(); Random random = new Random(); DateTime dtNow = dtStart; double prevClose = 100; for (int nIndex = 0; nIndex < count; nIndex++) { open = prevClose; if (prevClose < 25 || random.NextDouble() > 0.5) { // upward price change close = open + (2 + (random.NextDouble() * 20)); high = close + (random.NextDouble() * 10); low = open - (random.NextDouble() * 10); } else { // downward price change close = open - (2 + (random.NextDouble() * 20)); high = open + (random.NextDouble() * 10); low = close - (random.NextDouble() * 10); } if (low < 1) { low = 1; } prevClose = close; m_Stock.DataPoints.Add(new NStockDataPoint(NDateTimeHelpers.ToOADate(dtNow), open, close, high, low)); dtNow = span.Add(dtNow); } }