public bool downloadAdx(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData) { string interval = ddlAdx_Interval.SelectedValue; string period = textboxAdx_Period.Text; if (StockApi.getADX(folderPath, scriptName, day_interval: interval, period: period, bIsTestModeOn: bIsTestOn, bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null) { Response.Write("<script language=javascript>alert('ADX data not available for selected script.')</script>"); return(false); } return(true); }
public void ShowGraph(string scriptName) { string folderPath = Server.MapPath("~/scriptdata/"); bool bIsTestOn = true; DataTable scriptData = null; DataTable tempData = null; string expression = ""; string interval = ""; string period = ""; string seriestype = ""; string nbdevup = ""; string nbdevdn = ""; string fromDate = "", toDate = ""; DataRow[] filteredRows = null; if (ViewState["FetchedData"] == null) { if (Session["IsTestOn"] != null) { bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]); } if (Session["TestDataFolder"] != null) { folderPath = Session["TestDataFolder"].ToString(); } if ((Request.QueryString["interval"] != null) && (Request.QueryString["period"] != null) && (Request.QueryString["seriestype"] != null) && (Request.QueryString["nbdevup"] != null) && (Request.QueryString["nbdevdn"] != null)) { interval = Request.QueryString["interval"]; period = Request.QueryString["period"]; seriestype = Request.QueryString["seriestype"]; nbdevup = Request.QueryString["nbdevup"]; nbdevdn = Request.QueryString["nbdevdn"]; scriptData = StockApi.getADX(folderPath, scriptName, day_interval: interval, period: period, bIsTestModeOn: bIsTestOn, bSaveData: false); scriptData = StockApi.getBbands(folderPath, scriptName, day_interval: interval, period: period, seriestype: seriestype, nbdevup: nbdevup, nbdevdn: nbdevdn, bIsTestModeOn: bIsTestOn, bSaveData: false); } ViewState["FetchedData"] = scriptData; } else { if (ViewState["FromDate"] != null) { fromDate = ViewState["FromDate"].ToString(); } if (ViewState["ToDate"] != null) { toDate = ViewState["ToDate"].ToString(); } if ((fromDate.Length > 0) && (toDate.Length > 0)) { tempData = (DataTable)ViewState["FetchedData"]; expression = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'"; filteredRows = tempData.Select(expression); if ((filteredRows != null) && (filteredRows.Length > 0)) { scriptData = filteredRows.CopyToDataTable(); } } else { scriptData = (DataTable)ViewState["FetchedData"]; } } if (scriptData != null) { ////time,Real Lower Band,Real Middle Band,Real Upper Band /// (chartBollingerBands.Series["Real Lower Band"]).XValueMember = "Date"; (chartBollingerBands.Series["Real Lower Band"]).XValueType = ChartValueType.Date; (chartBollingerBands.Series["Real Lower Band"]).YValueMembers = "Real Lower Band"; //(chartBollingerBands.Series["Real Lower Band"]).ToolTip = "Lower Band: Date:#VALX; Value:#VALY"; (chartBollingerBands.Series["Real Middle Band"]).XValueMember = "Date"; (chartBollingerBands.Series["Real Middle Band"]).XValueType = ChartValueType.Date; (chartBollingerBands.Series["Real Middle Band"]).YValueMembers = "Real Middle Band"; //(chartBollingerBands.Series["Real Middle Band"]).ToolTip = "Middle Band: Date:#VALX; Value:#VALY"; (chartBollingerBands.Series["Real Upper Band"]).XValueMember = "Date"; (chartBollingerBands.Series["Real Upper Band"]).XValueType = ChartValueType.Date; (chartBollingerBands.Series["Real Upper Band"]).YValueMembers = "Real Upper Band"; //(chartBollingerBands.Series["Real Upper Band"]).ToolTip = "Upper Band: Date:#VALX; Value:#VALY"; //chartBollingerBands.Legends.Add("Real Lower Band"); //chartBollingerBands.Legends["Real Lower Band"].Docking = System.Web.UI.DataVisualization.Charting.Docking.Top; //chartBollingerBands.Legends["Real Lower Band"].LegendStyle = System.Web.UI.DataVisualization.Charting.LegendStyle.Row; //chartBollingerBands.Legends["Real Lower Band"].BorderDashStyle = System.Web.UI.DataVisualization.Charting.ChartDashStyle.Dash; //chartBollingerBands.Legends["Real Lower Band"].BorderColor = System.Drawing.Color.Black; //chartBollingerBands.Legends.Add("Real Middle Band"); //chartBollingerBands.Legends["Real Middle Band"].Docking = System.Web.UI.DataVisualization.Charting.Docking.Top; //chartBollingerBands.Legends["Real Middle Band"].LegendStyle = System.Web.UI.DataVisualization.Charting.LegendStyle.Row; //chartBollingerBands.Legends["Real Middle Band"].BorderDashStyle = System.Web.UI.DataVisualization.Charting.ChartDashStyle.Dash; //chartBollingerBands.Legends["Real Middle Band"].BorderColor = System.Drawing.Color.Black; //chartBollingerBands.Legends.Add("Real Upper Band"); //chartBollingerBands.Legends["Real Upper Band"].Docking = System.Web.UI.DataVisualization.Charting.Docking.Top; //chartBollingerBands.Legends["Real Upper Band"].LegendStyle = System.Web.UI.DataVisualization.Charting.LegendStyle.Row; //chartBollingerBands.Legends["Real Upper Band"].BorderDashStyle = System.Web.UI.DataVisualization.Charting.ChartDashStyle.Dash; //chartBollingerBands.Legends["Real Upper Band"].BorderColor = System.Drawing.Color.Black; chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisX.Title = "Date"; chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisX.TitleAlignment = System.Drawing.StringAlignment.Center; chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisY.Title = "Value"; chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisY.TitleAlignment = System.Drawing.StringAlignment.Center; //chartBollingerBands.Titles["titleBbands"].Text = $"{"Bollinger Bands - "}{scriptName}"; //VerticalLineAnnotation VA = new VerticalLineAnnotation(); //VA.AxisX = chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisX; //VA.IsInfinitive = true; //VA.ClipToChartArea = chartBollingerBands.ChartAreas["chartareaBollingerBands"].Name; //VA.Name = "myLine"; //VA.LineColor = System.Drawing.Color.Red; //VA.LineWidth = 10; // use your numbers! //HorizontalLineAnnotation HA = new HorizontalLineAnnotation(); //VA.AxisY = chartBollingerBands.ChartAreas["chartareaBollingerBands"].AxisY; //VA.IsInfinitive = true; //VA.ClipToChartArea = chartBollingerBands.ChartAreas["chartareaBollingerBands"].Name; //VA.Name = "myLine2"; //VA.LineColor = System.Drawing.Color.Red; //VA.LineWidth = 10; // use your numbers! //chartBollingerBands.Annotations.Add(VA); //chartBollingerBands.Annotations.Add(HA); if (chartBollingerBands.Annotations.Count > 0) { chartBollingerBands.Annotations.Clear(); } chartBollingerBands.DataSource = scriptData; chartBollingerBands.DataBind(); //VA.X = chartBollingerBands.Series[0].Points.FindMinByValue("X", 0).XValue; //VA.Y = chartBollingerBands.Series[0].Points.FindMinByValue("Y1", 0).YValues[0]; ; //chartBollingerBands.ChartAreas[0].AxisX.Minimum = chartBollingerBands.Series[0].Points.FindMinByValue("X", 0).XValue; //chartBollingerBands.ChartAreas[0].AxisX.Maximum = chartBollingerBands.Series[0].Points.FindMaxByValue("X", 0).XValue; // + 1; } }
public void ShowGraph(string scriptName) { string folderPath = Server.MapPath("~/scriptdata/"); bool bIsTestOn = true; DataTable scriptData = null; DataTable tempData = null; string expression = ""; string interval = ""; string period = ""; string fromDate = "", toDate = ""; DataRow[] filteredRows = null; if (ViewState["FetchedData"] == null) { if (Session["IsTestOn"] != null) { bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]); } if (Session["TestDataFolder"] != null) { folderPath = Session["TestDataFolder"].ToString(); } if ((Request.QueryString["interval"] != null) && (Request.QueryString["period"] != null)) { interval = Request.QueryString["interval"]; period = Request.QueryString["period"]; scriptData = StockApi.getADX(folderPath, scriptName, day_interval: interval, period: period, bIsTestModeOn: bIsTestOn, bSaveData: false); } ViewState["FetchedData"] = scriptData; } else { if (ViewState["FromDate"] != null) { fromDate = ViewState["FromDate"].ToString(); } if (ViewState["ToDate"] != null) { toDate = ViewState["ToDate"].ToString(); } if ((fromDate.Length > 0) && (toDate.Length > 0)) { tempData = (DataTable)ViewState["FetchedData"]; expression = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'"; filteredRows = tempData.Select(expression); if ((filteredRows != null) && (filteredRows.Length > 0)) { scriptData = filteredRows.CopyToDataTable(); } } else { scriptData = (DataTable)ViewState["FetchedData"]; } } if (scriptData != null) { ////time,Real Lower Band,Real Middle Band,Real Upper Band /// (chartADX.Series["seriesADX"]).XValueMember = "Date"; (chartADX.Series["seriesADX"]).XValueType = ChartValueType.Date; (chartADX.Series["seriesADX"]).YValueMembers = "ADX"; //(chartADX.Series["seriesADX"]).ToolTip = "ADX: Date:#VALX; Value:#VALY"; chartADX.ChartAreas["chartareaADX"].AxisX.Title = "Date"; chartADX.ChartAreas["chartareaADX"].AxisX.TitleAlignment = System.Drawing.StringAlignment.Center; chartADX.ChartAreas["chartareaADX"].AxisY.Title = "Value"; chartADX.ChartAreas["chartareaADX"].AxisY.TitleAlignment = System.Drawing.StringAlignment.Center; //chartADX.Titles["titleADX"].Text = $"{"Average Directional Movement Index- "}{scriptName}"; if (chartADX.Annotations.Count > 0) { chartADX.Annotations.Clear(); } chartADX.DataSource = scriptData; chartADX.DataBind(); } }