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


C# StockSerie.CalculateSAR方法代码示例

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


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

示例1: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            float accelerationFactorStart = (float)this.parameters[0];
             float accelerationFactorStep = (float)this.parameters[1];
             float accelerationFactorMax = (float)this.parameters[2];

             FloatSerie sarSupport;
             FloatSerie sarResistance;

             stockSerie.CalculateSAR(accelerationFactorStep, accelerationFactorStart, accelerationFactorMax, out sarSupport,
            out sarResistance, (int)this.parameters[3]);

             this.Series[0] = sarSupport;
             this.Series[1] = sarResistance;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);
             float previousHigh = stockSerie.Values.First().HIGH, previousLow = stockSerie.Values.First().LOW;
             float previousHigh2 = stockSerie.Values.First().HIGH, previousLow2 = stockSerie.Values.First().LOW;
             bool waitingForEndTrend = false;
             for (int i = 5; i < stockSerie.Count; i++)
             {
            if (float.IsNaN(sarResistance[i]) && !float.IsNaN(sarResistance[i - 1]))
            {
               this.Events[0][i] = true; // SupportDetected

               if (waitingForEndTrend)
               {
                  this.Events[3][i] = true; // EndOfTrend
                  waitingForEndTrend = false;
               }

               if (sarSupport[i] > previousLow)
               {
                  this.Events[4][i] = true; // HigherLow

                  if (sarSupport[i] > previousHigh2)
                  {
                     this.Events[2][i] = true; // PB
                     waitingForEndTrend = true;
                  }
               }
               previousLow2 = previousLow;
               previousLow = sarSupport[i];
            }
            if (float.IsNaN(sarSupport[i]) && !float.IsNaN(sarSupport[i - 1]))
            {
               this.Events[1][i] = true; // ResistanceDetected

               if (waitingForEndTrend)
               {
                  this.Events[3][i] = true; // EndOfTrend
                  waitingForEndTrend = false;
               }

               if (sarResistance[i] < previousHigh)
               {
                  this.Events[5][i] = true; // LowerHigh
                  if (sarResistance[i] < previousLow2)
                  {
                     this.Events[2][i] = true; // PB
                     waitingForEndTrend = true;
                  }
               }
               previousHigh2 = previousHigh;
               previousHigh = sarResistance[i];
            }

            this.Events[6][i] = false;
            this.Events[7][i] = false;
            this.Events[8][i] = float.IsNaN(sarResistance[i]);
            this.Events[9][i] = float.IsNaN(sarSupport[i]);
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:74,代码来源:StockIndicator_SAR.cs

示例2: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            float accelerationFactorStep = (float)this.parameters[0];
             float accelerationFactorMax = (float)this.parameters[1];

             FloatSerie sarSupport1;
             FloatSerie sarResistance1;

             FloatSerie sarSupport2;
             FloatSerie sarResistance2;

             float ratio = (float)this.parameters[2];

             stockSerie.CalculateSAR(accelerationFactorStep, accelerationFactorStep, accelerationFactorMax, out sarSupport1, out sarResistance1, 1);
             stockSerie.CalculateSAR2(accelerationFactorStep / ratio, accelerationFactorStep / ratio, accelerationFactorMax / ratio, sarSupport1, sarResistance1, out sarSupport2, out sarResistance2);

             this.Series[0] = sarSupport1;
             this.Series[1] = sarResistance1;

             this.Series[2] = sarSupport2;
             this.Series[3] = sarResistance2;

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

             for (int i = 5; i < stockSerie.Count; i++)
             {
            this.Events[0][i] = float.IsNaN(sarResistance1[i - 1]) && !float.IsNaN(sarResistance1[i]);
            this.Events[1][i] = float.IsNaN(sarSupport1[i - 1]) && !float.IsNaN(sarSupport1[i]);

            this.Events[2][i] = float.IsNaN(sarResistance2[i - 1]) && !float.IsNaN(sarResistance2[i]);
            this.Events[3][i] = float.IsNaN(sarSupport2[i - 1]) && !float.IsNaN(sarSupport2[i]);
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:34,代码来源:StockIndicator_SAR2.cs


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