https://www.codeproject.com/Questions/691857/How-to-get-max-value-of-a-column-in-datatable
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter();
//get all the tables from market data database
//String q1 = "SELECT name FROM market_data.sys.Tables where name not like '%_dss%' and name not like 'tick';";
//String q1 = "SELECT * FROM [market_data].[dbo].[" + txtSym.Text + "];";
string q1 = "SELECT top (20) [Volume] ,[Open],[High],[Low],[Close],[WAP],[Count],[dt],[EMA9],[EMA10],[EMA20],[EMA21],[EMA50],[EMA100],[EMA200] FROM [market_data].[dbo].[" + txtSym.Text + "];";
SqlCommand cmd = new SqlCommand(q1, cnn);
adapter.SelectCommand = cmd;
//Retrieve the records from database
adapter.Fill(ds);
DataRow[] result = ds.Tables[0].Select("Close = MAX(Close)");
double max = Convert.ToDouble(result[0][4].ToString()) + 5.00;
chart1.Series["Series1"].ChartType = SeriesChartType.Candlestick;
chart1.DataSource = ds;
No comments:
Post a Comment