zoukankan      html  css  js  c++  java
  • C#画K线图代码

        /// <summary>
        /// 获取K线图的画图数据
        /// </summary>
        /// <returns></returns>
        public override CandlePriceData[] GetPriceCandleData()
        {
            int i;
            float fStep, py1, py2, fpy1, fpy2;      


    if (ChartDataCount <= 4)    // 当数据小于5时
            {
                priceCandleData = new CandlePriceData[ChartDataCount];
                float fNewXSpace = 30;
                for (i = 0; i < ChartDataCount; i++)
                {
                    fStep = ChartData[ChartIndex + i].Open - MinVal;
                    py1 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].Close - MinVal;
                    py2 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].Low - MinVal;
                    fpy1 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].High - MinVal;
                    fpy2 = (historySkin.FirstLine - fStep / PriceEveryHAverage);              


    if (py2 - py1 > 0)//跌
                    {
                        priceCandleData[i].RectanglePointF = new System.Drawing.PointF(historySkin.MarginLeft + i * fNewXSpace, py2);//计算矩形的左上角坐标
                        priceCandleData[i].IsUp = true;
                        priceCandleData[i].RectangleHeigh = py2 - py1;
                    }
                    else { priceCandleData[i].RectanglePointF = new System.Drawing.PointF(historySkin.MarginLeft + i * fNewXSpace, py1);
                        priceCandleData[i].IsUp = false;
                        priceCandleData[i].RectangleHeigh = py1 - py2; } priceCandleData[i].RectangleWidth = fNewXSpace-1;
                    priceCandleData[i].LineOneStart = new System.Drawing.PointF(historySkin.MarginLeft + 15 + i * fNewXSpace, fpy1);
                    priceCandleData[i].LineOneEnd = new System.Drawing.PointF(historySkin.MarginLeft + 15 + i * fNewXSpace, py1);
                    priceCandleData[i].LineTwoStart = new System.Drawing.PointF(historySkin.MarginLeft + 15 + i * fNewXSpace, py2);
                    priceCandleData[i].LineTwoEnd = new System.Drawing.PointF(historySkin.MarginLeft + 15 + i * fNewXSpace, fpy2);
                }
            }
            else
            {
                priceCandleData = new CandlePriceData[ChartDataCount];          


    for (i = 0; i < ChartDataCount; i++)
                {
                    fStep = ChartData[ChartIndex + i].Open - MinVal;
                    py1 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].Close - MinVal;
                    py2 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].Low - MinVal;
                    fpy1 = (historySkin.FirstLine - fStep / PriceEveryHAverage);
                    fStep = ChartData[ChartIndex + i].High - MinVal;
                    fpy2 = (historySkin.FirstLine - fStep / PriceEveryHAverage);              


    if (py2 - py1 > 0)//跌
                    {
                        if (py2 - py1 < 1)
                        {
                            py2 = py1 + 1;
                        }
                        priceCandleData[i].RectanglePointF = new System.Drawing.PointF(historySkin.MarginLeft+Fpx1+i*EveryHorizontalSpace, py1);
                        priceCandleData[i].IsUp = false;
                        priceCandleData[i].RectangleHeigh = py2 - py1;                    priceCandleData[i].LineOneEnd


    = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, py1);
                        priceCandleData[i].LineOneStart = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, fpy2); priceCandleData[i].LineTwoStart = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, py2);
                        priceCandleData[i].LineTwoEnd = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, fpy1);
                    }
                    else
                    {
                        if (py1 - py2 < 1)
                        {
                            py1 = py2 + 1;
                        }                    priceCandleData[i].RectanglePointF


    = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + i * EveryHorizontalSpace, py2);
                        priceCandleData[i].IsUp = true;
                        priceCandleData[i].RectangleHeigh = py1 - py2;                    priceCandleData[i].LineOneEnd


    = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, py2);
                        priceCandleData[i].LineOneStart = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, fpy2);
                        priceCandleData[i].LineTwoStart = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, py1);
                        priceCandleData[i].LineTwoEnd = new System.Drawing.PointF(historySkin.MarginLeft + Fpx1 + Fpx + i * EveryHorizontalSpace, fpy1);
                    }                priceCandleData[i].RectangleWidth


    = EveryHorizontalSpace-1;
                }
            }
            return priceCandleData;
        }

  • 相关阅读:
    Veritca 简单安装配置过程
    本地环回,引发的血案
    Centos8的网络管理
    在做自动化测试之前你需要知道的什么是自动化测?
    APP移动测试用例总结
    Appium做Android功能自动化测试
    Selenium Webdriver模拟鼠标键盘操作
    线程锁 创建两个线程,其中一个输出152,另外一个输出AZ。要求使用线程锁,使输出为: 12A 34B 56C 78D Y
    Win10安装MongoDb Y
    linux下Docker安装 Y
  • 原文地址:https://www.cnblogs.com/chuncn/p/1442962.html
Copyright © 2011-2022 走看看