Example #1
0
        public static DataSeries <Value> DonchianPct(this DataSeries <Bar> bars, int period, Func <Bar, double> getValue)
        {
            var dMin        = bars.DonchianMin(period);
            var dMax        = bars.DonchianMax(period);
            var newElements = Lists.Create <Value>();

            DataSeries.Walk(bars, dMin, dMax, pos => {
                newElements.Add(new Value(bars[0].Timestamp, (getValue(bars[0]) - dMin[0]) / (dMax[0] - dMin[0])));
            });
            return(new DataSeries <Value>(bars.Symbol, newElements));
        }
Example #2
0
 public static DataSeries <Value> DonchianAvg(this DataSeries <Bar> bars, int period)
 {
     return(bars.DonchianMin(period).ZipElements <Value, Value>(bars.DonchianMax(period), (min, max, v) => (min[0] + max[0]) / 2));
 }