Ejemplo n.º 1
0
        public void DisplayView()
        {
            chart.Update();

            int scrollVal = hScrollBar.Value;

            if (scrollVal < hScrollBar.Minimum)
            {
                scrollVal = hScrollBar.Minimum;
            }
            if (scrollVal > hScrollBar.Maximum)
            {
                scrollVal = hScrollBar.Maximum;
            }

            int trackView        = trackBar.Value;
            int displayItemCount = DisplayPointCount * trackView;

            List <T_QuantumItemData> viewLists        = null;
            List <T_QuantumItemData> viewAvgLists     = null;
            List <T_QuantumItemData> viewAvgBLists    = null;
            List <SmartCandleData>   viewSmartLists   = null;
            List <SmartCandleData>   viewSmartBLists  = null;
            List <double>            viewPMForceLists = null;
            int maxDisplayIndex = 0;
            int minDisplayIndex = 0;

            if (scrollVal == hScrollBar.Minimum)
            {
                int maxIndex = ChartData.Count > displayItemCount ? displayItemCount - 1 : ChartData.Count;
                if (displayItemCount > ChartData.Count)
                {
                    displayItemCount = ChartData.Count;
                }
                viewLists        = ChartData.GetRange(0, maxIndex);
                viewAvgLists     = ChartDataSub.GetRange(0, maxIndex);
                viewAvgBLists    = ChartDataSub2.GetRange(0, maxIndex);
                viewSmartLists   = smartDataList.GetRange(0, maxIndex);
                viewSmartBLists  = smartBDataList.GetRange(0, maxIndex);
                viewPMForceLists = pmForceList.GetRange(0, maxIndex);
                maxDisplayIndex  = displayItemCount;
                minDisplayIndex  = 0;
            }
            else if (scrollVal == hScrollBar.Maximum)
            {
                int minIndex = ChartData.Count < displayItemCount ? 0 : ChartData.Count - displayItemCount;
                if (displayItemCount > ChartData.Count)
                {
                    displayItemCount = ChartData.Count;
                }
                viewLists        = ChartData.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);
                viewAvgLists     = ChartDataSub.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);
                viewAvgBLists    = ChartDataSub2.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);
                viewSmartLists   = smartDataList.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);
                viewSmartBLists  = smartBDataList.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);
                viewPMForceLists = pmForceList.GetRange(minIndex, ChartData.Count < displayItemCount ? ChartData.Count : displayItemCount);

                maxDisplayIndex = ChartData.Count;
                minDisplayIndex = minIndex;
            }
            else
            {
                //int currentIndex = (scrollVal - 1) * displayItemCount;
                int currentIndex = (scrollVal - 1);
                if (ChartData.Count < currentIndex + displayItemCount)
                {
                    displayItemCount = ChartData.Count - currentIndex;
                }

                viewLists        = ChartData.GetRange(currentIndex, displayItemCount);
                viewAvgLists     = ChartDataSub.GetRange(currentIndex, displayItemCount);
                viewAvgBLists    = ChartDataSub2.GetRange(currentIndex, displayItemCount);
                viewSmartLists   = smartDataList.GetRange(currentIndex, displayItemCount);
                viewSmartBLists  = smartBDataList.GetRange(currentIndex, displayItemCount);
                viewPMForceLists = pmForceList.GetRange(currentIndex, displayItemCount);

                maxDisplayIndex = currentIndex + displayItemCount;
                minDisplayIndex = currentIndex;
            }

            if (viewLists != null)
            {
                foreach (var ca in chart.ChartAreas)
                {
                    ca.AxisX.Maximum = maxDisplayIndex - 3;
                    ca.AxisX.Minimum = minDisplayIndex - 1;
                }
                double maxPrice = viewLists.Max(m => m.HighPrice);
                double minPrice = viewLists.Min(m => m.LowPrice);
                double devation = (maxPrice - minPrice) / 10.0;
                maxPrice = maxPrice + SpaceMaxMin;
                minPrice = minPrice - SpaceMaxMin;
                chart.ChartAreas["ca1"].AxisY2.Maximum = maxPrice;
                chart.ChartAreas["ca1"].AxisY2.Minimum = minPrice;
                chart.ChartAreas["ca1"].AxisY.Maximum  = viewAvgLists.Max(m => m.T_ElectronForceAvg) + 0.5;
                chart.ChartAreas["ca1"].AxisY.Minimum  = viewAvgLists.Min(m => m.T_ElectronForceAvg) - 0.5;


                maxPrice = viewAvgLists.Max(m => m.HighPrice);
                minPrice = viewAvgLists.Min(m => m.LowPrice);
                double devationAvg = (maxPrice - minPrice) / 10.0;
                maxPrice = maxPrice + SpaceMaxMin;
                minPrice = minPrice - SpaceMaxMin;
                chart.ChartAreas["ca2"].AxisY2.Maximum = maxPrice;
                chart.ChartAreas["ca2"].AxisY2.Minimum = minPrice;

                maxPrice = viewAvgBLists.Max(m => m.HighPrice);
                minPrice = viewAvgBLists.Min(m => m.LowPrice);
                maxPrice = maxPrice + SpaceMaxMin + 1;
                minPrice = minPrice - SpaceMaxMin - 1;
                chart.ChartAreas["ca3"].AxisY2.Maximum = maxPrice;
                chart.ChartAreas["ca3"].AxisY2.Minimum = minPrice;

                maxPrice = viewSmartLists.Max(m => m.Variance_ChartPrice3);
                minPrice = viewSmartLists.Min(m => m.Variance_ChartPrice3);
                maxPrice = maxPrice + SpaceMaxMin + 1;
                minPrice = minPrice - SpaceMaxMin - 1;
                //maxPrice = smartDataList.GetRange(2, smartDataList.Count - 3).Max(m => m.Variance_ChartPrice2);
                //maxPrice = smartDataList.GetRange(2, smartDataList.Count - 3).Min(m => m.Variance_ChartPrice2);
                chart.ChartAreas["ca4"].AxisY2.Maximum = maxPrice;
                chart.ChartAreas["ca4"].AxisY2.Minimum = minPrice;

                maxPrice = viewSmartBLists.Max(m => m.Variance_ChartPrice3);
                minPrice = viewSmartBLists.Min(m => m.Variance_ChartPrice3);
                maxPrice = maxPrice + SpaceMaxMin;
                minPrice = minPrice - SpaceMaxMin;
                //maxPrice = smartBDataList.GetRange(2, smartBDataList.Count - 3).Max(m => m.Variance_ChartPrice2);
                //maxPrice = smartBDataList.GetRange(2, smartBDataList.Count - 3).Min(m => m.Variance_ChartPrice2);
                chart.ChartAreas["ca5"].AxisY2.Maximum = maxPrice;
                chart.ChartAreas["ca5"].AxisY2.Minimum = minPrice;

                chart.ChartAreas["ca6"].AxisY2.Maximum = viewPMForceLists.Max();
                chart.ChartAreas["ca6"].AxisY2.Minimum = viewPMForceLists.Min();

                var pList = PPUtils.GetExceptPlusMinusList(ChartData, PlusMinusTypeEnum.양);
                var mList = PPUtils.GetExceptPlusMinusList(ChartData, PlusMinusTypeEnum.음);
                //double devation = ItemCodeSet.GetDeviation(ItemCode);

                resistanceList    = PPUtils.GetResistancePrices(pList, devation, 3, 3);
                supportList       = PPUtils.GetSupportPrices(mList, devation, 3, 3);
                resistanceAvgList = PPUtils.GetResistancePrices(ChartDataSub, devationAvg, 3, 3);
                supportAvgList    = PPUtils.GetSupportPrices(ChartDataSub, devationAvg, 3, 3);

                RemoveAnnotationsByTag("RS");
                DisplayResistanceAndSupportLine();
                DisplayAvgResistanceAndSupportLine();
            }
        }