Exemple #1
0
        protected internal override void Calculate(int index)
        {
            if (this.calculate)
            {
                this.Calculate();
                return;
            }
            if (this.style == IndicatorStyle.QuantStudio)
            {
                double num  = 0.0;
                double num2 = 0.0;
                if (index >= this.length)
                {
                    if (index == this.length)
                    {
                        for (int i = index; i >= index - this.length + 1; i--)
                        {
                            num2 += TR.Value(this.input, i);
                            num  += PDM.Value(this.input, i);
                        }
                    }
                    else
                    {
                        num  = this.pdmTS[index - 1] - PDM.Value(this.input, index - this.length) + PDM.Value(this.input, index);
                        num2 = this.trTS[index - 1] - TR.Value(this.input, index - this.length) + TR.Value(this.input, index);
                    }
                    if (num2 != 0.0)
                    {
                        double num3 = num / num2 * 100.0;
                        if (!double.IsNaN(num3))
                        {
                            base.Add(this.input.GetDateTime(index), num3);
                        }
                    }
                }
                this.pdmTS.Add(this.input.GetDateTime(index), num);
                this.trTS.Add(this.input.GetDateTime(index), num2);
                return;
            }
            double num4 = 0.0;
            double num5 = 0.0;

            if (index >= this.length)
            {
                if (index == this.length)
                {
                    for (int j = index; j >= index - this.length + 1; j--)
                    {
                        num5 += TR.Value(this.input, j);
                        num4 += PDM.Value(this.input, j);
                    }
                }
                else
                {
                    num4 = this.pdmTS[index - 1] - this.pdmTS[index - 1] / (double)this.length + PDM.Value(this.input, index);
                    num5 = this.trTS[index - 1] - this.trTS[index - 1] / (double)this.length + TR.Value(this.input, index);
                }
                if (num5 != 0.0)
                {
                    double num6 = num4 / num5 * 100.0;
                    if (!double.IsNaN(num6))
                    {
                        base.Add(this.input.GetDateTime(index), num6);
                    }
                }
            }
            this.pdmTS.Add(this.input.GetDateTime(index), num4);
            this.trTS.Add(this.input.GetDateTime(index), num5);
        }
Exemple #2
0
 protected internal override void Calculate(int index)
 {
     if (this.calculate)
     {
         this.Calculate();
         return;
     }
     if (index >= this.length)
     {
         int    num = -1 * this.length;
         double value;
         if (this.style == IndicatorStyle.QuantStudio)
         {
             if (index == this.length)
             {
                 double num2 = 0.0;
                 for (int i = index; i > index - this.length; i--)
                 {
                     num2 += TR.Value(this.input, i);
                 }
                 value = num2 / (double)this.length;
             }
             else
             {
                 double num3 = TR.Value(this.input, index);
                 value = (this[index - 1 + num] * (double)this.length + num3 - TR.Value(this.input, index - this.length)) / (double)this.length;
             }
         }
         else
         {
             if (index == this.length)
             {
                 double num4 = 0.0;
                 for (int j = index; j > index - this.length; j--)
                 {
                     num4 += TR.Value(this.input, j);
                 }
                 value = num4 / (double)this.length;
             }
             else
             {
                 double num3 = TR.Value(this.input, index);
                 value = (base[this.input.GetDateTime(index - 1), SearchOption.Exact] * (double)this.length + num3 - TR.Value(this.input, index - this.length)) / (double)this.length;
             }
         }
         base.Add(this.input.GetDateTime(index), value);
     }
 }