Пример #1
0
 public void 包含计算()
 {
     #region
     Bar bar1, bar2;
     int ind = bars.Count - 1;
     int bh1, bh2, bh3;
     int bl1, bl2, bl3;
     if (ind > 2)
     {
         bar1 = bars[ind];
         bar2 = bars[ind - 1];
         bh1  = MathHelper.ConvertToInt(bar1.High);
         bh2  = MathHelper.ConvertToInt(bar2.High);
         bl1  = MathHelper.ConvertToInt(bar1.Low);
         bl2  = MathHelper.ConvertToInt(bar2.Low);
         if ((bh1 >= bh2) && (bl1 <= bl2))
         {
             if (blist1.Count == 0)
             {
                 return;
             }
             if (blist1.Last().zd == 结构.底)
             {
                 bar1.Low = bar2.Low;
                 bars.Remove(bar2);
             }
             if (blist1.Last().zd == 结构.顶)
             {
                 bar1.High = bar2.High;
                 bars.Remove(bar2);
             }
             return;
         }
         if ((bh1 <= bh2 && (int)bl1 >= bl2))
         {
             if (blist1.Count == 0)
             {
                 return;
             }
             if (blist1.Last().zd == 结构.底)
             {
                 bar2.Low = bar1.Low;
                 bars.Remove(bar1);
             }
             if (blist1.Last().zd == 结构.顶)
             {
                 bar2.High = bar1.High;
                 bars.Remove(bar1);
             }
         }
     }
     #endregion
     Bar ba1, ba2, ba3;
     笔   bi = new 笔();
     ind = bars.Count - 1;
     if (ind > 7)
     {
         ba1 = bars[ind - 2];
         ba2 = bars[ind - 1];
         ba3 = bars[ind];
         bh1 = MathHelper.ConvertToInt(ba1.High);
         bh2 = MathHelper.ConvertToInt(ba2.High);
         bh3 = MathHelper.ConvertToInt(ba3.High);
         bl1 = MathHelper.ConvertToInt(ba1.Low);
         bl2 = MathHelper.ConvertToInt(ba2.Low);
         bl3 = MathHelper.ConvertToInt(ba3.Low);
         if ((bh2 > bh1 && bh2 > bh3) && (bl2 > bl1 && bl2 > bl3))
         {
             if (blist1.Count == 0)
             {
                 bi.zd    = 结构.顶;
                 bi.o     = 0;
                 bi.high  = bh2;
                 bi.low   = bl2;
                 bi.ba    = ba2;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
             if (blist1.Last().zd == 结构.顶 && bh1 > MathHelper.ConvertToInt(blist1.Last().high))
             {
                 blist1.Remove(blist1.Last());
                 bi.zd    = 结构.顶;
                 bi.o     = 0;
                 bi.high  = bh2;
                 bi.low   = bl2;
                 bi.ba    = ba2;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
             if (blist1.Last().zd == 结构.底 && ind > blist1.Last().index + 4 && bh1 > MathHelper.ConvertToInt(blist1.Last().high))
             {
                 bi.zd    = 结构.顶;
                 bi.o     = 0;
                 bi.high  = bh2;
                 bi.low   = bl2;
                 bi.ba    = ba2;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
         }
         if ((bh2 < bh1 && bh2 < bh3) && (bl2 < bl1 && bl2 < bl3))
         {
             if (blist1.Count == 0)
             {
                 bi.zd    = 结构.底;
                 bi.o     = 0;
                 bi.high  = bh2;
                 bi.low   = bl2;
                 bi.ba    = ba2;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
             if (blist1.Last().zd == 结构.底 && bl1 < MathHelper.ConvertToInt(blist1.Last().low))
             {
                 blist1.Remove(blist1.Last());
                 bi.zd    = 结构.底;
                 bi.o     = 0;
                 bi.high  = bh2;
                 bi.low   = bl2;
                 bi.ba    = ba2;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
             if (blist1.Last().zd == 结构.顶 && ind > blist1.Last().index + 4 && bl1 < MathHelper.ConvertToInt(blist1.Last().low))
             {
                 bi.zd    = 结构.底;
                 bi.o     = 0;
                 bi.high  = bh1;
                 bi.low   = bl1;
                 bi.ba    = ba1;
                 bi.index = ind - 1;
                 blist1.Add(bi);
             }
         }
     }
 }