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


C# StockSerie.GenerateHeikinAshiBarFromDaily方法代码示例

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


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

示例1: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            using (MethodLogger ml = new MethodLogger(this))
             {
            List<StockDailyValue> dailyValues = stockSerie.GenerateHeikinAshiBarFromDaily(stockSerie.Values.ToList());
            FloatSerie upVolume = new FloatSerie(stockSerie.Count);
            FloatSerie downVolume = new FloatSerie(stockSerie.Count);

            int i = -1;
            foreach (StockDailyValue dailyValue in dailyValues)
            {
               i++;
               float R = dailyValue.HIGH - dailyValue.LOW; // Bar range

               float R2 = Math.Abs(dailyValue.CLOSE - dailyValue.OPEN); // Body range

               if (R == 0 || R2 == 0)
               {
                  upVolume[i] = downVolume[i] = dailyValue.VOLUME / 2L;
                  continue;
               }

               float R1 = dailyValue.HIGH - Math.Max(dailyValue.CLOSE, dailyValue.OPEN); // Higher shade range
               float R3 = Math.Min(dailyValue.CLOSE, dailyValue.OPEN) - dailyValue.LOW; // Lower shade range

               float V = dailyValue.VOLUME;
               float V1 = V * (R1 / R);
               float V2 = V * (R2 / R);
               float V3 = V * (R3 / R);

               if (dailyValue.CLOSE > dailyValue.OPEN) // UpBar
               {
                  upVolume[i] = V2 + (V1 + V3) / 2.0f;
                  downVolume[i] = V - upVolume[i];
               }
               else // DownBar
               {
                  downVolume[i] = V2 + (V1 + V3) / 2.0f;
                  upVolume[i] = V - downVolume[i];
               }

               //V = V(R1/R) + V(R2/R) + V(R3/R);

            }

            //FloatSerie upVolume = stockSerie.GetSerie(StockDataType.UPVOLUME).Sqrt();
            //FloatSerie downVolume = stockSerie.GetSerie(StockDataType.DOWNVOLUME).Sqrt();
            FloatSerie cumulVolume = (upVolume - downVolume).Cumul();
            FloatSerie diffVolume = (cumulVolume - cumulVolume.CalculateEMA((int)this.parameters[0])).CalculateEMA((int)this.parameters[1]);
            FloatSerie fastSerie = diffVolume;

            FloatSerie fastMom = fastSerie;
            this.series[0] = fastMom;
            this.Series[0].Name = this.Name;

            FloatSerie signalSerie = fastMom.CalculateEMA(((int)this.parameters[2]));
            this.series[1] = signalSerie;
            this.Series[1].Name = this.SerieNames[1];

            if (this.series[0] != null && this.Series[0].Count > 0)
            {
               this.CreateEventSeries(stockSerie.Count);

               FloatSerie upExLimit = new FloatSerie(stockSerie.Count, this.SerieNames[1]);
               FloatSerie downExLimit = new FloatSerie(stockSerie.Count, this.SerieNames[2]);
               FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
               FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);

               FloatSerie indicatorToDecorate = this.Series[0];
               float exhaustionSellLimit = indicatorToDecorate[0];
               float exhaustionBuyLimit = indicatorToDecorate[0];
               float exhaustionBuyPrice = highSerie[0];
               float exhaustionSellPrice = lowSerie[0];
               float exFadeOut = (100.0f - (float)this.parameters[3]) / 100.0f;

               float previousValue = indicatorToDecorate[0];
               float currentValue;

               for (i = 1; i < indicatorToDecorate.Count - 1; i++)
               {
                  currentValue = indicatorToDecorate[i];

                  if (currentValue < previousValue)
                  {
                     if (indicatorToDecorate.IsBottom(i))
                     {
                        if (currentValue <= exhaustionSellLimit)
                        {
                           // This is an exhaustion selling
                           exhaustionSellPrice = lowSerie[i];
                           exhaustionSellLimit = currentValue;
                        }
                        else
                        {
                           exhaustionSellLimit *= exFadeOut;
                        }
                        exhaustionBuyLimit *= exFadeOut;
                     }
                     else
                     { // trail exhaustion limit down
//.........这里部分代码省略.........
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:StockIndicator_VOLMOMEX.cs


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