public static double Value(ISeries input, int index, int length1, int length2) { if (index >= Math.Max(length1, length2)) { var ad = new AD(input); var ema1 = new EMA(ad, length1); var ema2 = new EMA(ad, length2); return ema1[index] - ema2[index]; } return double.NaN; }
protected override void Init() { this.name = $"CAD ({this.length1}, {this.length2})"; this.description = "Chaikin A/D Oscillator"; Clear(); this.calculate = true; Detach(); this.ad?.Detach(); this.ema1?.Detach(); this.ema2?.Detach(); this.ad = new AD(this.input); this.ema1 = new EMA(this.ad, this.length1); this.ema2 = new EMA(this.ad, this.length2); Attach(); }