当前位置: 首页>>代码示例>>C#>>正文


C# StockSerie.CalculateHilbertSR方法代码示例

本文整理汇总了C#中StockSerie.CalculateHilbertSR方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.CalculateHilbertSR方法的具体用法?C# StockSerie.CalculateHilbertSR怎么用?C# StockSerie.CalculateHilbertSR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StockSerie的用法示例。


在下文中一共展示了StockSerie.CalculateHilbertSR方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie hilbertSupport, hilbertResistance, secondarySupport, secondaryResistance;
             IStockIndicator hilbertIndicator = stockSerie.GetIndicator("HILBERT(" + (int)this.Parameters[0] + ")");
             stockSerie.CalculateHilbertSR(hilbertIndicator, (int)this.Parameters[1], out hilbertSupport, out hilbertResistance, out secondarySupport, out secondaryResistance);
             this.Series[0] = hilbertSupport;
             this.Series[1] = hilbertResistance;
             this.Series[2] = secondarySupport;
             this.Series[3] = secondaryResistance;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
             float lastSupportLevel = hilbertResistance[0];
             float lastResistanceLevel = hilbertResistance[0];
             bool waitingEndOfUpTrend = false;
             bool waitingEndOfDownTrend = false;
             bool supportDetected = false;
             bool resistanceDetected = false;
             for (int i = 10; i < stockSerie.Count; i++)
             {
            if (float.IsNaN(hilbertResistance[i]))
            {
               // Set UpSwing
               this.eventSeries[4][i] = closeSerie[i] > hilbertSupport[i];
               // Set DownTrend
               this.eventSeries[7][i] = closeSerie[i] < hilbertSupport[i];
            }
            else
            {
               // Set DownSwing
               this.eventSeries[5][i] = closeSerie[i] < hilbertResistance[i];
               // Set UpTrend
               this.eventSeries[6][i] = closeSerie[i] > hilbertResistance[i];
            }

            supportDetected = float.IsNaN(hilbertSupport[i - 1]) && !float.IsNaN(hilbertSupport[i]);
            this.eventSeries[0][i] = supportDetected;

            if (supportDetected)
            {
               if (waitingEndOfDownTrend && hilbertSupport[i] <= lastResistanceLevel) // End of down trend
               {
                  this.eventSeries[3][i] = true;
                  waitingEndOfDownTrend = false; // In any case we don't wait for the EOT as either it's reached or the trend changed.
               }
               else
               {
                  if (hilbertSupport[i] >= lastResistanceLevel) // Pullback in up trend
                  {
                     this.eventSeries[2][i] = true;
                     waitingEndOfUpTrend = true;
                     waitingEndOfDownTrend = false;
                  }
                  else
                  {
                     waitingEndOfUpTrend = false;
                  }
               }
               lastSupportLevel = hilbertSupport[i];
               continue;
            }

            resistanceDetected = float.IsNaN(hilbertResistance[i - 1]) && !float.IsNaN(hilbertResistance[i]);
            this.eventSeries[1][i] = resistanceDetected;

            if (resistanceDetected)
            {
               if (waitingEndOfUpTrend && lastSupportLevel <= hilbertResistance[i]) // End of up trend
               {
                  this.eventSeries[3][i] = true;
                  waitingEndOfUpTrend = false; // In any case we don't wait for the EOT as either it's reached or the trend changed.
               }
               else
               {
                  if (lastSupportLevel >= hilbertResistance[i]) // Pullback in down trend
                  {
                     this.eventSeries[2][i] = true;
                     waitingEndOfUpTrend = false;
                     waitingEndOfDownTrend = true;
                  }
                  else
                  {
                     waitingEndOfUpTrend = false;
                     waitingEndOfUpTrend = false;
                  }
               }
               lastResistanceLevel = hilbertResistance[i];
            }
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:92,代码来源:StockIndicator_HILBERTSR.cs


注:本文中的StockSerie.CalculateHilbertSR方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。