Example #1
0
File: CAD.cs Project: heber/FreeOQ
 public static double Value(TimeSeries input, int index, int length1, int length2)
 {
   if (index < Math.Max(length1, length2) + input.FirstIndex)
     return double.NaN;
   AD ad = new AD(input);
   EMA ema1 = new EMA((TimeSeries) ad, length1);
   EMA ema2 = new EMA((TimeSeries) ad, length2);
   return ema1[index] - ema2[index];
 }
Example #2
0
File: CAD.cs Project: heber/FreeOQ
    protected override void Init()
    {
			this.Name = "CAD" + (object) this.fLength1 + (string) (object) this.fLength2;
			this.Title ="CAD";
      this.Clear();
      this.fCalculate = true;
      if (this.fInput == null)
        return;
			if (TimeSeries.fNameOption == ENameOption.Long)
				this.Name = this.fInput.Name + this.Name;
      this.Disconnect();
      if (this.fAD != null)
        this.fAD.Detach();
      if (this.fEMA1 != null)
        this.fEMA1.Detach();
      if (this.fEMA2 != null)
        this.fEMA2.Detach();
      this.fAD = new AD(this.fInput);
      this.Connect();
      this.fEMA1 = new EMA((TimeSeries) this.fAD, this.fLength1);
      this.fEMA2 = new EMA((TimeSeries) this.fAD, this.fLength2);
      this.fAD.DrawEnabled = false;
      this.fEMA1.DrawEnabled = false;
      this.fEMA1.DrawEnabled = false;
    }
Example #3
0
        public static double Value(TimeSeries input, int index)
        {
            double num1 = 0.0;

            if (index >= input.FirstIndex)
            {
                double num2 = input[index, BarData.High];
                double num3 = input[index, BarData.Low];
                double num4 = input[index, BarData.Close];
                double num5 = input[index, BarData.Open];
                double num6 = input[index, BarData.Volume];
                if (index >= input.FirstIndex + 1)
                {
                    num1 = num2 == num3?AD.Value(input, index - 1) : num6 * (num4 - num3 - (num2 - num4)) / (num2 - num3) + AD.Value(input, index - 1);
                }
                if (index == input.FirstIndex && num2 != num3)
                {
                    num1 = num6 * (num4 - num3 - (num2 - num4)) / (num2 - num3);
                }
            }
            else
            {
                num1 = double.NaN;
            }
            return(num1);
        }