예제 #1
0
        protected override void Calculate(int index)
        {
            double Data1 = double.NaN;

            if (this.fStyle == EIndicatorStyle.QuantStudio)
            {
                double Data2 = 0.0;
                double Data3 = 0.0;
                if (index >= this.fLength + this.fInput.FirstIndex)
                {
                    if (index == this.fLength + this.fInput.FirstIndex)
                    {
                        for (int index1 = index; index1 >= index - this.fLength + 1; --index1)
                        {
                            Data3 += TR.Value(this.fInput, index1);
                            Data2 += PDM.Value(this.fInput, index1);
                        }
                    }
                    else
                    {
                        Data2 = this.fPDM[index - 1] - PDM.Value(this.fInput, index - this.fLength) + PDM.Value(this.fInput, index);
                        Data3 = this.fTR[index - 1] - TR.Value(this.fInput, index - this.fLength) + TR.Value(this.fInput, index);
                    }
                    if (Data3 != 0.0)
                    {
                        Data1 = Data2 / Data3 * 100.0;
                    }
                }
                this.fPDM.Add(this.fInput.GetDateTime(index), Data2);
                this.fTR.Add(this.fInput.GetDateTime(index), Data3);
            }
            else
            {
                double Data2 = 0.0;
                double Data3 = 0.0;
                if (index >= this.fLength + this.fInput.FirstIndex)
                {
                    if (index == this.fLength + this.fInput.FirstIndex)
                    {
                        for (int index1 = index; index1 >= index - this.fLength + 1; --index1)
                        {
                            Data3 += TR.Value(this.fInput, index1);
                            Data2 += PDM.Value(this.fInput, index1);
                        }
                    }
                    else
                    {
                        Data2 = this.fPDM[index - 1] - this.fPDM[index - 1] / (double)this.fLength + PDM.Value(this.fInput, index);
                        Data3 = this.fTR[index - 1] - this.fTR[index - 1] / (double)this.fLength + TR.Value(this.fInput, index);
                    }
                    if (Data3 != 0.0)
                    {
                        Data1 = Data2 / Data3 * 100.0;
                    }
                }
                this.fPDM.Add(this.fInput.GetDateTime(index), Data2);
                this.fTR.Add(this.fInput.GetDateTime(index), Data3);
            }
            this.Add(this.fInput.GetDateTime(index), Data1);
        }
예제 #2
0
 public static double Value(TimeSeries input, int index, int length, EIndicatorStyle style)
 {
     if (style == EIndicatorStyle.QuantStudio)
     {
         double num1 = 0.0;
         double num2 = 0.0;
         if (index < length + input.FirstIndex)
         {
             return(double.NaN);
         }
         for (int index1 = index; index1 > index - length; --index1)
         {
             num2 += TR.Value(input, index1);
             num1 += PDM.Value(input, index1);
         }
         return(num1 / num2 * 100.0);
     }
     else
     {
         double num1 = 0.0;
         double num2 = 0.0;
         if (index < length + input.FirstIndex)
         {
             return(double.NaN);
         }
         for (int index1 = length + input.FirstIndex; index1 >= input.FirstIndex + 1; --index1)
         {
             num2 += TR.Value(input, index1);
             num1 += PDM.Value(input, index1);
         }
         for (int index1 = length + 1 + input.FirstIndex; index1 <= index; ++index1)
         {
             num1 = num1 - num1 / (double)length + PDM.Value(input, index1);
             num2 = num2 - num2 / (double)length + TR.Value(input, index1);
         }
         return(num1 / num2 * 100.0);
     }
 }
예제 #3
0
 protected override void Calculate(int index)
 {
     if (this.fStyle == EIndicatorStyle.QuantStudio)
     {
         double Data1 = 0.0;
         double Data2 = 0.0;
         double Data3 = 0.0;
         if (index >= this.fLength + this.fInput.FirstIndex)
         {
             if (index == this.fLength + this.fInput.FirstIndex)
             {
                 for (int index1 = index; index1 >= index - this.fLength + 1; --index1)
                 {
                     Data1 += PDM.Value(this.fInput, index1);
                     Data2 += MDM.Value(this.fInput, index1);
                 }
             }
             else
             {
                 Data2 = this.fMDM[index - 1] - MDM.Value(this.fInput, index - this.fLength) + MDM.Value(this.fInput, index);
                 Data1 = this.fPDM[index - 1] - PDM.Value(this.fInput, index - this.fLength) + PDM.Value(this.fInput, index);
             }
             if (Data1 + Data2 != 0.0)
             {
                 Data3 = Math.Abs(Data1 - Data2) / (Data1 + Data2) * 100.0;
             }
             this.Add(this.fInput.GetDateTime(index), Data3);
         }
         else
         {
             this.Add(this.fInput.GetDateTime(index), double.NaN);
         }
         this.fPDM.Add(this.fInput.GetDateTime(index), Data1);
         this.fMDM.Add(this.fInput.GetDateTime(index), Data2);
     }
     else
     {
         double Data1 = 0.0;
         double Data2 = 0.0;
         double Data3 = 0.0;
         if (index >= this.fLength + this.fInput.FirstIndex)
         {
             if (index == this.fLength + this.fInput.FirstIndex)
             {
                 for (int index1 = index; index1 >= index - this.fLength + 1; --index1)
                 {
                     Data1 += PDM.Value(this.fInput, index1);
                     Data2 += MDM.Value(this.fInput, index1);
                 }
             }
             else
             {
                 Data1 = this.fPDM[index - 1] - this.fPDM[index - 1] / (double)this.fLength + PDM.Value(this.fInput, index);
                 Data2 = this.fMDM[index - 1] - this.fMDM[index - 1] / (double)this.fLength + MDM.Value(this.fInput, index);
             }
             if (Data1 + Data2 != 0.0)
             {
                 Data3 = Math.Abs(Data1 - Data2) / (Data1 + Data2) * 100.0;
             }
             this.Add(this.fInput.GetDateTime(index), Data3);
         }
         else
         {
             this.Add(this.fInput.GetDateTime(index), double.NaN);
         }
         this.fPDM.Add(this.fInput.GetDateTime(index), Data1);
         this.fMDM.Add(this.fInput.GetDateTime(index), Data2);
     }
 }
예제 #4
0
        protected override void Calculate(int index)
        {
            double Data = PDM.Value(this.fInput, index);

            this.Add(this.fInput.GetDateTime(index), Data);
        }