protected internal override void Calculate(int index) { if (this.calculate) { this.Calculate(); return; } double num = PDM.Value(this.input, index); if (!double.IsNaN(num)) { base.Add(this.input.GetDateTime(index), num); } }
public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio) { if (style == IndicatorStyle.QuantStudio) { double num = 0.0; double num2 = 0.0; if (index >= length) { for (int i = index; i > index - length; i--) { num2 += TR.Value(input, i); num += PDM.Value(input, i); } return(num / num2 * 100.0); } return(double.NaN); } else { double num3 = 0.0; double num4 = 0.0; if (index >= length) { for (int j = length; j >= 1; j--) { num4 += TR.Value(input, j); num3 += PDM.Value(input, j); } for (int k = length + 1; k <= index; k++) { num3 = num3 - num3 / (double)length + PDM.Value(input, k); num4 = num4 - num4 / (double)length + TR.Value(input, k); } return(num3 / num4 * 100.0); } return(double.NaN); } }
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); }
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; double value = 0.0; if (index >= this.length) { if (index == this.length) { for (int i = index; i >= index - this.length + 1; i--) { num += PDM.Value(this.input, i); num2 += MDM.Value(this.input, i); } } else { num2 = this.mdmTS[index - 1] - MDM.Value(this.input, index - this.length) + MDM.Value(this.input, index); num = this.pdmTS[index - 1] - PDM.Value(this.input, index - this.length) + PDM.Value(this.input, index); } if (num + num2 != 0.0) { value = Math.Abs(num - num2) / (num + num2) * 100.0; } base.Add(this.input.GetDateTime(index), value); } this.pdmTS.Add(this.input.GetDateTime(index), num); this.mdmTS.Add(this.input.GetDateTime(index), num2); return; } double num3 = 0.0; double num4 = 0.0; double value2 = 0.0; if (index >= this.length) { if (index == this.length) { for (int j = index; j >= index - this.length + 1; j--) { num3 += PDM.Value(this.input, j); num4 += MDM.Value(this.input, j); } } else { num3 = this.pdmTS[index - 1] - this.pdmTS[index - 1] / (double)this.length + PDM.Value(this.input, index); num4 = this.mdmTS[index - 1] - this.mdmTS[index - 1] / (double)this.length + MDM.Value(this.input, index); } if (num3 + num4 != 0.0) { value2 = Math.Abs(num3 - num4) / (num3 + num4) * 100.0; } base.Add(this.input.GetDateTime(index), value2); } this.pdmTS.Add(this.input.GetDateTime(index), num3); this.mdmTS.Add(this.input.GetDateTime(index), num4); }