public DVCFE(Bars bars, int period1, int period2, int rankPeriod, string description) : base(bars, description) { if (FirstValidValue > bars.Count || FirstValidValue < 0) { FirstValidValue = bars.Count; } if (bars.Count < Math.Max(rankPeriod, Math.Max(period1, period2))) { return; } //Step 1 DataSeries PriceChange = DataSeries.Abs(ROC.Series(bars.Close, 1)); //Step 2 DataSeries TenDayPriceChange = bars.Close - (bars.Close >> period1); DataSeries FirstRatio = (TenDayPriceChange / Sum.Series(PriceChange, period1)) * -1; //Step 3 DataSeries TwoFiftyDayPriceChange = bars.Close - (bars.Close >> period2); DataSeries SecondRatio = (TwoFiftyDayPriceChange / Sum.Series(PriceChange, period2)); //Step 4 DataSeries Average = (FirstRatio + SecondRatio) / 2; DataSeries DVCFE = PrcRank.Series(Average, rankPeriod); base.FirstValidValue = Math.Max(Math.Max(period1, period2), rankPeriod); if (FirstValidValue == 1) { return; } for (int bar = base.FirstValidValue; bar < bars.Count; bar++) { base[bar] = DVCFE[bar]; } }
public static PrcRank Series(DataSeries ds, int period) { string description = string.Concat(new object[] { "PrcRank(", ds.Description, ",", period, ")" }); if (ds.Cache.ContainsKey(description)) { return((PrcRank)ds.Cache[description]); } PrcRank _pr = new PrcRank(ds, period, description); ds.Cache[description] = _pr; return(_pr); }
public DV2Bounded(Bars bars, int period, string description) : base(bars, description) { this.bars = bars; this.period = period; base.FirstValidValue = period + 2; if (FirstValidValue > bars.Count || FirstValidValue < 0) { FirstValidValue = bars.Count; } if (bars.Count < period) { return; } dv2 = PrcRank.Series(DV2Partial.Series(bars), period); for (int bar = FirstValidValue; bar < bars.Count; bar++) { base[bar] = dv2[bar]; } }