public bool downloadEMA(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData)
        {
            string interval = ddlEMA_Interval.SelectedValue;
            string period   = textboxEMA_Period.Text;
            string series   = ddlEMA_Series.SelectedValue;

            if (StockApi.getEMA(folderPath, scriptName, day_interval: interval, period: period, seriestype: series, bIsTestModeOn: bIsTestOn, bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            {
                Response.Write("<script language=javascript>alert('EMA data not available for selected script.')</script>");
                return(false);
            }
            return(true);
        }
Example #2
0
        public void ShowGraph(string scriptName)
        {
            string    folderPath = Server.MapPath("~/scriptdata/");
            bool      bIsTestOn = true;
            DataTable scriptData = null;
            DataTable tempData = null;
            string    expression = "";
            string    period = "";
            string    seriestype = "";
            string    interval = "";
            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["period"] != null) && (Request.QueryString["interval"] != null) && (Request.QueryString["seriestype"] != null))
                {
                    interval   = Request.QueryString["interval"];
                    period     = Request.QueryString["period"].ToString();
                    seriestype = Request.QueryString["seriestype"].ToString();

                    scriptData = StockApi.getEMA(folderPath, scriptName, day_interval: interval, period: period,
                                                 seriestype: seriestype, 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
                ///
                (chartEMA.Series["seriesEMA"]).XValueMember  = "Date";
                (chartEMA.Series["seriesEMA"]).XValueType    = ChartValueType.Date;
                (chartEMA.Series["seriesEMA"]).YValueMembers = "EMA";
                //(chartEMA.Series["seriesEMA"]).ToolTip = "EMA: Date:#VALX;   Value:#VALY";

                chartEMA.ChartAreas["chartareaEMA"].AxisX.Title          = "Date";
                chartEMA.ChartAreas["chartareaEMA"].AxisX.TitleAlignment = System.Drawing.StringAlignment.Center;
                chartEMA.ChartAreas["chartareaEMA"].AxisY.Title          = "Value";
                chartEMA.ChartAreas["chartareaEMA"].AxisY.TitleAlignment = System.Drawing.StringAlignment.Center;

                //chartEMA.Titles["titleEMA"].Text = $"{"Exponential Moving Average- "}{scriptName}";

                if (chartEMA.Annotations.Count > 0)
                {
                    chartEMA.Annotations.Clear();
                }

                chartEMA.DataSource = scriptData;
                chartEMA.DataBind();
            }
        }