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


C# StockSerie.CalculateFastOscillator方法代码示例

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


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

示例1: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie slowK = stockSerie.CalculateFastOscillator((int)this.parameters[0]).CalculateEMA((int)this.parameters[1]);
             FloatSerie slowD = slowK.CalculateEMATrailStop((int)this.parameters[2],1);
             this.series[0] = slowK;
             this.series[0].Name = this.SerieNames[0];
             this.series[1] = slowD;
             this.series[1].Name = this.SerieNames[1];

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

             float overbought = (float)this.parameters[3];
             float oversold = (float)this.parameters[4];

             bool isOverSold = false;
             bool isOverBought = false;

             for (int i = 1; i < slowK.Count; i++)
             {
            this.eventSeries[0][i] = (slowD[i - 1] > slowK[i - 1] && slowD[i] < slowK[i]);
            this.eventSeries[1][i] = (slowD[i - 1] < slowK[i - 1] && slowD[i] > slowK[i]);
            isOverSold = slowK[i] <= oversold;
            isOverBought = slowK[i] >= overbought;
            this.eventSeries[2][i] = isOverBought;
            this.eventSeries[3][i] = isOverSold;
            this.eventSeries[4][i] = (!isOverSold) && this.eventSeries[3][i - 1];
            this.eventSeries[5][i] = (!isOverBought) && this.eventSeries[2][i - 1];
            this.eventSeries[6][i] = slowK[i] > slowD[i];
            this.eventSeries[7][i] = slowK[i] < slowD[i];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:32,代码来源:StockIndicator_STOKS.cs

示例2: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie fastK = stockSerie.CalculateFastOscillator((int)this.parameters[0]).Div(100.0f).Sub(0.5f);

             FloatSerie oscSerie = new FloatSerie(stockSerie.Count);

             int i = 0;
             StockDailyValue previousValue = null;
             float previousOSCValue = 0.0f;
             foreach (StockDailyValue dailyValue in stockSerie.Values)
             {
            if (previousValue != null)
            {
               if (fastK[i] > 0)
               {
                  previousOSCValue += (1.0f - previousOSCValue) * fastK[i];
               }
               else
               {
                  previousOSCValue -= (-1.0f - previousOSCValue) * fastK[i];
               }

               oscSerie[i] = previousOSCValue;
            }
            previousValue = dailyValue;
            i++;

             }

             this.series[0] = oscSerie;
             this.Series[0].Name = this.Name;

             FloatSerie signalSerie = oscSerie.CalculateEMA((int)this.parameters[1]);
             this.series[1] = signalSerie;
             this.series[1].Name = this.series[0].Name + "_SIGNAL";

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);
             for (i = 2; i < oscSerie.Count; i++)
             {
            this.eventSeries[0][i] = (oscSerie[i] > signalSerie[i]);
            this.eventSeries[1][i] = (oscSerie[i] < signalSerie[i]);
            this.eventSeries[0][i] = eventSeries[0][i] & !eventSeries[0][i - 1];
            this.eventSeries[1][i] = eventSeries[1][i] & !eventSeries[1][i - 1];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:46,代码来源:StockIndicator_MYOSC.cs


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