你不能在你自己的帖子上投票 0
我正在尝试在每日数据上创建一个带有 MA(15) 的股票蜡烛。
我可以毫无问题地创建带有 OHLC 条的图表。
但是当我开始使用 MA 的 DataManipulator.FinancialFormula 时,我不断收到“公式错误 - 期间没有足够的数据点”的错误。
有人可以帮我解决这个问题吗?谢谢
这是代码。
DataSet ds = new DataSet();
SqlConnection connection = new SqlConnection();
connection.ConnectionString = @"Data Source=XXX;Database=Stock;Integrated Security=SSPI;";
connection.Open();
string sql = "Select datestamp, highprice, lowprice,openprice, closeprice from daymarketdata where tickname='GS' and datestamp>'1/1/2011' order by datestamp asc";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, connection);
cmd.CommandType = CommandType.Text;
SqlDataAdapter sa = new SqlDataAdapter();
sa.SelectCommand = cmd;
sa.Fill(ds, "Cos");
connection.Close();
chart1.Series["Daily"].ChartType = SeriesChartType.Candlestick;
chart1.DataSource = sa;
chart1.DataBind();
chart1.Series["Daily"].XValueMember = "DateStamp";
chart1.Series["Daily"].YValueMembers = "HighPrice, LowPrice, OpenPrice, ClosePrice";
chart1.Series["Daily"].IsXValueIndexed = true;
chart1.Series["Daily"].BorderColor = System.Drawing.Color.Black;
chart1.Series["Daily"].Color = System.Drawing.Color.Black;
chart1.Series["Daily"].CustomProperties = "PriceDownColor=Green, PriceUpColor=Red";
chart1.Series["Daily"].XValueType = ChartValueType.Date;
chart1.ChartAreas[0].AxisY.Minimum = 100;
chart1.ChartAreas[0].AxisY.Maximum = 180;
chart1.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage, "15", "Daily", "MA");