Esempio n. 1
0
        /* ***************************************************************************************************************************************************************
         * If you click one of the bars in the bouncegraph representing a recovery period this will replace the stock price details in the line chart to reflect just the
         * days of the recovery period you selected.
         * *************************************************************************************************************************************************************** */

        private void BounceGraph_Click(object sender, EventArgs e)
        {
            // If you click in the graph AND the mouse is on a series column the stock detail will redisplay for that period  (Date - Recover days)

            //MessageBox.Show("click", Convert.ToString(BG_Detail.i_ToolTip_col));


            // Interesting thing happens here.  The first selection you make after a grid reset doesn't catch here?
            // It acts like you have to double click the first row to take an action?
            string dgr_symbol = "xxx";

            double gvb_TodaysPrice = 0.0;
            int    gvb_Tickerid    = 0;
            string gvb_Date;

            double dstartprice = 0.0;
            int    istart      = 0;
            int    istop       = 0;

            // There's no analysis in this loop.  Just look up the pricepoints and add them to the graph when you hit the Ticker ID and keep going for recover days.

            if (!Form_BounceinProgress)
            {
                // Initialize the query
                BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BGCQ;
                BGCQ = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter();

                // We're pulling a detailed set from the existing symbol.
                dgr_symbol = BounceChart.Series[0].Name;

                BounceData2DataSet.DailyQuoteDataTable List_BouncePoints;
                List_BouncePoints = BGCQ.GetDataBySymbol(dgr_symbol);


                BounceChart.Series[0].Points.Clear();


                // It would be cleaner to hold the actual row instead of the Ticker ID but I don't want to go back to fix it.
                // Loop through the records to find the ticker ID.  Back up one day because we want to see the drop.


                for (int i = 1; i < List_BouncePoints.Rows.Count; i++)
                {
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open");

                    if (gvb_Tickerid == Convert.ToInt32(Form_BounceGraph_DT.Rows[BG_Detail.i_ToolTip_col - 1]["TickerID"]))
                    {
                        istop = i;
                        i     = List_BouncePoints.Rows.Count + 1;
                    }
                }

                if (istop > 0)
                {
                    istart      = istop - (Convert.ToInt32(Form_BounceGraph_DT.Rows[BG_Detail.i_ToolTip_col - 1]["RecoverDays"]) + 1);
                    dstartprice = List_BouncePoints.Rows[istart].Field <double>("open");
                }



                for (int i = istart; i <= istop; i++)
                {
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open") - dstartprice;
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_Date        = List_BouncePoints.Rows[i].Field <string>("date");

                    BounceChart.Series[0].Points.AddXY(i - istart + 1, gvb_TodaysPrice);
                }
            }
        }
Esempio n. 2
0
        /* ***************************************************************************************************************************************************************
         *  This is the best routine I found to identify when a user picks a symbol from the list of symbols.
         *  It will display the stock activity for that ticker in the line chart on the bottom right of the form
         *  and the times that stock dropped below the percent entered in a single day with the days it took to recover as
         *  the bar chart amount.
         * *************************************************************************************************************************************************************** */

        private void dataGridVBounce_CellRowEnter(object sender, DataGridViewCellEventArgs e)
        {
            // Interesting thing happens here.  The first selection you make after a grid reset doesn't catch here?
            // It acts like you have to double click the first row to take an action?
            string dgr_symbol = "xxx";

            bool DummyFlag = false;

            int bri = e.RowIndex;

            double gvb_TodaysPrice = 0.0;
            int    gvb_Tickerid    = 0;
            string gvb_Date;
            int    gvb_counter = 0;

            StockAnalysis gvb_Look = new StockAnalysis();

            gvb_Look.ClearBounces();

            DummyFlag = Check_on_pct(gvb_Look);



            if (!Form_BounceinProgress)
            {
                // OK so I'm changing things up here a bit.  Instead of adding XY elements to bouncegraph I'm going to fill a datatable bound to the graph in the stock analyis routines.
                // This section will be respobsible for clearing the table and setting the global row value.

                //BounceinProgress = true;

                dgr_symbol = dataGridVBounce.Rows[bri].Cells[0].Value.ToString();

                DataRow dr;

                // Initialize the query


                BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BBDGQ;
                BBDGQ = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter();

                BounceData2DataSet.DailyQuoteDataTable List_BouncePoints;
                List_BouncePoints = BBDGQ.GetDataBySymbol(dgr_symbol);


                BounceChart.Series[0].Points.Clear();

                BounceChart.Series[0].Name = dgr_symbol;

                //BounceGraph.Series[0].Points.Clear();
                Form_BounceGraph_DT.Clear();



                for (int i = 1; i < List_BouncePoints.Rows.Count; i++)
                {
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open");
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_Date        = List_BouncePoints.Rows[i].Field <string>("date");
                    BounceChart.Series[0].Points.AddXY(i, gvb_TodaysPrice);

                    // Here I want to run through the same logic the bounce process did when looking up all symbols.
                    // Then display the bounced days in the Bouncegraph chart.
                    gvb_Look.SetPricePoint(gvb_Tickerid, gvb_TodaysPrice, gvb_Date);

                    // Check to see if a bounce was recorded.
                    if (gvb_Look.sa_PriceBounces > gvb_counter)
                    {
                        gvb_counter = gvb_Look.sa_PriceBounces;

                        dr                = Form_BounceGraph_DT.NewRow();
                        dr["DropDate"]    = gvb_Look.sa_DropDate;
                        dr["GraphDays"]   = Convert.ToString(Math.Min(BG_Detail.i_gmax, gvb_Look.sa_BounceDay[gvb_counter]));
                        dr["RecoverDays"] = Convert.ToString(gvb_Look.sa_BounceDay[gvb_counter]);
                        dr["Price"]       = Convert.ToString(gvb_Look.sa_PricePoint);
                        dr["DropPct"]     = gvb_Look.sa_DropPct;
                        dr["TickerID"]    = Convert.ToString(gvb_Tickerid);


                        Form_BounceGraph_DT.Rows.Add(dr);
                    }
                }


                // Set the row after everything is full.
                BG_Detail.i_Rows = gvb_Look.sa_PriceBounces;
                BG_Detail.Set_Boundary();

                BounceGraph.DataSource = Form_BounceGraph_DT;
                BounceGraph.Series["Days"].XValueMember  = "DropDate";
                BounceGraph.Series["Days"].YValueMembers = "GraphDays";



                BounceGraph.DataBind();
            }
        }