public HiLoLimit(Bars bars, int period, double level, double minrange, string description) : base(bars, description) { for (int bar = period; bar < bars.Count; bar++) { double result = 0.0; double ls = Lowest.Series(bars.Low, period)[bar]; double ds = HiLoRange.Series(bars, period)[bar]; if (minrange == 0.0) { result = ls + (ds * (level / 100)); } else { double l = ls; double range = ds; double mid = l + range / 2; double mrange = l * minrange / 100.0; if (range < mrange) { range = mrange; } result = mid + (level / 100.0 - 0.5) * range; } base[bar] = result; } }
public static HiLoRange Series(Bars bars, int period) { string description = string.Concat(new object[] { "HiLoRange(", period.ToString(), ")" }); if (bars.Cache.ContainsKey(description)) { return((HiLoRange)bars.Cache[description]); } HiLoRange _HiLoRange = new HiLoRange(bars, period, description); bars.Cache[description] = _HiLoRange; return(_HiLoRange); }