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;
Sunday, January 27, 2019
Monday, January 21, 2019
SQL select with timestamp
SELECT ...
FROM ...
WHERE MyDate BETWEEN '2005-07-12 07:00:00' and '2005-07-12 08:00:00'
SELECT TOP (9) [Volume]
,[Open]
,[High]
,[Low]
,[Close]
,[WAP]
,[Count]
,[dt]
,[EMA9]
,[EMA10]
,[EMA20]
,[EMA21]
,[EMA50]
,[EMA100]
,[EMA200]
FROM [market_data].[dbo].[NFLX]
WHERE dt <= '2019-01-18 19:42:00'
FROM ...
WHERE MyDate BETWEEN '2005-07-12 07:00:00' and '2005-07-12 08:00:00'
SELECT TOP (9) [Volume]
,[Open]
,[High]
,[Low]
,[Close]
,[WAP]
,[Count]
,[dt]
,[EMA9]
,[EMA10]
,[EMA20]
,[EMA21]
,[EMA50]
,[EMA100]
,[EMA200]
FROM [market_data].[dbo].[NFLX]
WHERE dt <= '2019-01-18 19:42:00'
Subscribe to:
Posts (Atom)