//populate public override void Populate() { TimeSeries source = Parameters[0].AsTimeSeries; Int32 period = Parameters[1].AsInt; Double rsival = Parameters[2].AsDouble; DateTimes = source.DateTimes; //Prepare intermediate series TimeSeries UC = new TimeSeries(DateTimes); // up change TimeSeries DC = new TimeSeries(DateTimes); // down change for (int bar = 0; bar < source.Count; bar++) { UC[bar] = 0d; DC[bar] = 0d; } for (int bar = 1; bar < source.Count; bar++) { if (source[bar] > source[bar - 1]) { UC[bar] = source[bar] - source[bar - 1]; } else { DC[bar] = source[bar - 1] - source[bar]; } } TimeSeries AUC = new EMA(UC, 2 * period - 1); TimeSeries ADC = new EMA(DC, 2 * period - 1); AUC.Abs(); //Assign first bar that contains indicator data int FirstValidIdx = source.FirstValidIndex + 2 * period - 1; if (FirstValidIdx > source.Count) { FirstValidIdx = source.Count; } //modify the code below to implement your own indicator calculation for (int n = FirstValidIdx; n < source.Count; n++) { double value = (period - 1) * (ADC[n] * rsival / (100 - rsival) - AUC[n]); if (value < 0) { value *= (100 - rsival) / rsival; } Values[n] = source[n] + value; } }