1. <blockquote id="xmzy0"></blockquote>
    <u id="xmzy0"></u>
    1. 人妻一本久道久久综合鬼色,色噜噜在线视频免费观看,亚洲护士一区二区三区,亚洲国产精品久久久久秋霞 ,久久精品久久黄色片看看,国产成人精品久久性色av,成人3D动漫一区二区三区,亚洲综合成人av在线
         您現在的位置: 南方財富網 >> 股票知識 >> K線圖 >> 正文
      南方財富搜索

      DrawOneKLine如何畫單根K線

      2010-9-2 9:13:06   來源:不詳   佚名
          

      //函數實現畫單根K線的功能,坐標為普通坐標,而非對數坐標

      void CStockGraph::DrawOneKLine(CDC * pDC, int nIndexPos, int nIndexKD, CKData * pKData, double dMin, double dMax, BOOL bGreyed )
      {
       DECLARE_COLOR_DEFINATION

       // Check Valid

       //判斷當前位置的序列號是否有效,指的是顯示窗口,在當前的m_nIndexStart 和 m_nIndexEnd之間
       ASSERT( pDC && nIndexPos >= m_nIndexStart && nIndexPos <= m_nIndexEnd && nIndexPos >= 0 );
       if( !(pDC && nIndexPos >= m_nIndexStart && nIndexPos <= m_nIndexEnd && nIndexPos >= 0) )
        return;

       //判斷當前位置的序列號是否有效,序列號是否是小于零或大于當前序列的長度
       if( !pKData || nIndexKD < 0 || nIndexKD >= pKData->GetSize() )
        return;
       if( dMax-dMin < 1e-4 )
        return;

       // Get Region

       //關于GetOneKLineRect請參看下面關于這個函數的分析

       //這里需要注意的一個問題就是rectK, rcEntity,是有不同的含義的,rectK是指顯示的K線矩形區域,實際的畫K線的區域是rcEntity,指的是畫K線實體的區域
       CRect rectK, rcEntity;
       long xMedium = 0;
       if( !GetOneKLineRect( nIndexPos, &rectK, &rcEntity.left, &rcEntity.right, &xMedium ) )//參數xMedium 為K線實體的中間位置,對應畫K線的圖形
        return;

       int xStart = rectK.left;
       int xEnd = rectK.right;
       ASSERT( xEnd <= m_rectKLineCenter.right );
       if( xEnd > m_rectKLineCenter.right )
        return;

       KDATA kd = pKData->ElementAt(nIndexKD);

      //根據當前最低價格/最高價格/收盤價格/開盤價格的計算出K線實體在當前顯示區域中坐標.(等比例的計算)

       // Set rcEntity's top and bottom, set yLow, yHigh
       int yLow = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fLow - dMin) / (dMax-dMin) );
       int yHigh = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fHigh - dMin) / (dMax-dMin) );
       int yOpen = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fOpen - dMin) / (dMax-dMin) );
       int yClose = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kd.m_fClose - dMin) / (dMax-dMin) );

       //計算出實體區域的上下坐標,左右坐標已經根據序列位置計算出來了,到這個地方,已經計算出了要畫K線的試題區域的具體坐標了.

       rcEntity.top = min( yOpen, yClose );
       rcEntity.bottom = max( yOpen, yClose ) + 1;

       

       //上面已經計算出了要畫的K線的坐標了,下面就開始畫K線了

       if( CStockGraph::klineCandle == m_nCurKLineMode )
       {
        // Draw Entity

        //畫實體區域了
        COLORREF clr = clrRise;
        if( kd.m_fClose < kd.m_fOpen )
         clr = clrFallEntity;
        if( kd.m_date > m_dwLatestDate )
         clr = clrNewKLine;
        if( bGreyed )
         clr = clrDJ;
        pDC->SetBkColor( clrBK );
        if( kd.m_fClose < kd.m_fOpen )
         pDC->FillSolidRect( &rcEntity, clr );
        else
         pDC->Draw3dRect( &rcEntity, clr, clr );
       
        // Draw Line

        //畫K線上的最高和最低價格的線
        CPen pen( PS_SOLID, 1, clr );
        CPen *pOldPen = pDC->SelectObject( &pen );
        pDC->MoveTo( xMedium, yHigh );
        pDC->LineTo( xMedium, rcEntity.top );
        pDC->MoveTo( xMedium, rcEntity.bottom );
        pDC->LineTo( xMedium, yLow );

        pDC->SelectObject( pOldPen );
       }
       else if( CStockGraph::klineAmerica == m_nCurKLineMode )
       {
        // Draw Entity
        COLORREF clr = clrRise;
        if( kd.m_date > m_dwLatestDate )
         clr = clrNewKLine;
        if( bGreyed )
         clr = clrDJ;
        pDC->SetBkColor( clrBK );
       
        // Draw Line
        CPen pen( PS_SOLID, 1, clr );
        CPen *pOldPen = pDC->SelectObject( &pen );
        pDC->MoveTo( xStart, yHigh );
        pDC->LineTo( xStart, yLow );
        pDC->MoveTo( xStart, yClose );
        pDC->LineTo( xEnd, yClose );

        pDC->SelectObject( pOldPen );
       }
       else if( CStockGraph::klineTower == m_nCurKLineMode )
       {
       
        // Draw Entity
        COLORREF clr = clrRise;
        if( kd.m_fClose < kd.m_fOpen )
         clr = clrFallEntity;
        if( kd.m_date > m_dwLatestDate )
         clr = clrNewKLine;
        if( bGreyed )
         clr = clrDJ;
        pDC->SetBkColor( clrBK );
        if( kd.m_fClose < kd.m_fOpen )
         pDC->FillSolidRect( &rcEntity, clr );
        else
         pDC->Draw3dRect( &rcEntity, clr, clr );

        if( nIndexKD > 0 )
        {
         KDATA kdLast = pKData->ElementAt(nIndexKD-1);
         int yOpenLast = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kdLast.m_fOpen - dMin) / (dMax-dMin) );
         int yCloseLast = int( m_rectKLineCenter.bottom - m_rectKLineCenter.Height() * (kdLast.m_fClose - dMin) / (dMax-dMin) );
         if( kdLast.m_fClose > kdLast.m_fOpen && kd.m_fClose < kd.m_fOpen )
         {
          rcEntity.bottom = min(yOpenLast,rcEntity.bottom);
          if( rcEntity.bottom > rcEntity.top )
          {
           pDC->FillSolidRect( &rcEntity, clrBK );
           clr = clrRise;
           if( kd.m_date > m_dwLatestDate )
            clr = clrNewKLine;
           if( bGreyed )
            clr = clrDJ;
           pDC->Draw3dRect( &rcEntity, clr, clr );
          }
         }
         else if( kdLast.m_fClose < kdLast.m_fOpen && kd.m_fClose > kd.m_fOpen )
         {
          rcEntity.top = max(yOpenLast,rcEntity.top);
          if( rcEntity.bottom > rcEntity.top )
          {
           clr = clrFallEntity;
           if( kd.m_date > m_dwLatestDate )
            clr = clrNewKLine;
           if( bGreyed )
            clr = clrDJ;
           pDC->FillSolidRect( &rcEntity, clr );
          }
         }
        }
       }
      }

       

      //函數GetOneKLineRect的分析,得到當前序列位置處要畫K線的區域

      BOOL CStockGraph::GetOneKLineRect( int nIndex, LPRECT lpRect, long *pxEntityLeft, long *pxEntityRight, long *pxMedium )
      {

       //判斷當前的序列位置是在當前顯示的窗口區域中
       if( nIndex == -1 || nIndex < m_nIndexStart || nIndex > m_nIndexEnd )
        return FALSE;

       //初始化畫K線的位置的矩形區域

       CRect rectK = m_rectCenter;

       //計算出K線位置的左右寬度的坐標,上下的坐標沒有給出,只是初始化為m_rectCenter中的參數

       //左邊的起誓位置為,從K線顯示區域的左邊開始m_rectKLineCenter.left,加上已經顯示了nIndex-m_nIndexStart點的距離就是當前序列處的坐標
       rectK.left = m_rectKLineCenter.left + (nIndex-m_nIndexStart) * m_nThickness;

      //右邊的坐標最簡單,就是左邊左邊加上寬度就可以了.
       rectK.right = rectK.left + m_nThickness;

       if( rectK.Width() <= 0 || rectK.Height() <= 0 )
        return FALSE;

      //傳出參數lpRect
       if( lpRect )
        *lpRect = rectK;

       int xStart = rectK.left;

       CRect rcEntity;

       //根據當前的K線的寬度計算出序列的右邊的坐標點,并傳出參數
       switch( m_nThickness )
       {
       case 1:
       case 2:
        rcEntity.left = xStart;
        rcEntity.right = xStart + 1;
        break;
       case 4:
       case 5:
        rcEntity.left = xStart;
        rcEntity.right = xStart + 3;
        break;
       case 6:
       case 7:
        rcEntity.left = xStart;
        rcEntity.right = xStart + 5;
        break;
       case 9:
       case 10:
        rcEntity.left = xStart;
        rcEntity.right = xStart + 7;
        break;
       case 13:
       case 15:
        rcEntity.left = xStart;
        rcEntity.right = xStart + 11;
        break;
       default:
        ASSERT( FALSE );
        rcEntity.left = xStart;
        rcEntity.right = xStart + 3;
        return FALSE;
       }
       if( pxEntityLeft )
        *pxEntityLeft = rcEntity.left;
       if( pxEntityRight )
        *pxEntityRight = rcEntity.right;
       if( pxMedium )
        *pxMedium = rcEntity.left + rcEntity.Width() / 2;

       return TRUE;
      }

      (責任編輯:張元緣)
          南方財富網聲明:股市資訊來源于合作媒體及機構,屬作者個人觀點,僅供投資者參考,并不構成投資建議。投資者據此操作,風險自擔。
      商務進行時
      每日必讀
      學院24小時排行
      證券導讀
      熱圖推薦

      關于南方財富網版權聲明誠聘英才廣告服務網站地圖友情鏈接
      特此聲明:廣告商的言論與行為均與南方財富網無關
      www.605668.cn
      南方財富網 © 版權所有 閩ICP備09035581號
      主站蜘蛛池模板: 亚洲成人av在线高清| 国产一区二区在线观看粉嫩| 国产深夜福利在线免费观看| 国产成人av乱码在线观看| 欧美特黄一免在线观看| 国产成年码av片在线观看| 无码天堂亚洲国产av麻豆| 国内精品极品久久免费看| 日韩精品中文字幕国产一| 久久精品国产www456c0m| 日本边添边摸边做边爱喷水| 国产精品亚洲二区在线播放| 亚洲国产成人无码影院| 国产免费又黄又爽又色毛| 青草成人在线视频观看| 国产传媒剧情久久久av| 骚虎视频在线观看| 2020年最新国产精品正在播放| 人妻精品动漫H无码中字| 国产午夜A理论毛片| 国产精品无码无在线观看| 免费国产一级特黄aa大片在线| 日韩大片高清播放器| 国产va欧美va在线观看| 高级艳妇交换俱乐部小说| 国产av一区二区三区丝袜| 99热这里都是国产精品| 久久精品夜色噜噜亚洲aa| 欧美白妞大战非洲大炮| 精品视频在线观看免费观看| 国产亚洲精品第一综合另类灬| 国产综合视频一区二区三区| 人妻少妇88久久中文字幕| 国产精品亚洲综合一区二区 | 国产一区二区一卡二卡| 成人拍拍拍无遮挡免费视频| 亚洲av无码国产在丝袜线观看| 亚洲成人精品一区免费| 在线观看无码av免费不卡网站| 国产毛片子一区二区三区| 最新国产精品好看的精品|