示例#1
0
文件: WLMA.cs 项目: ToniTsai/LeetCode
        public WLMA(Bars bars, DataSeries ds, int swings, string description)
            : base(bars, description)
        {
            AdaptiveLookback al = AdaptiveLookback.Series(bars, swings, false);

            base.FirstValidValue = al.FirstValidValue;

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                base[bar] = Community.Indicators.FastSMA.Series(ds, Math.Max(1, (int)al[bar]))[bar];
            }
        }
示例#2
0
        public static AdaptiveLookback Series(Bars bars, int howManySwings, bool UseAll)
        {
            string description = string.Concat(new object[] { "Adaptive Lookback(", howManySwings.ToString(), ",", UseAll.ToString(), ")" });

            if (bars.Cache.ContainsKey(description))
            {
                return((AdaptiveLookback)bars.Cache[description]);
            }

            AdaptiveLookback _AdaptiveLookback = new AdaptiveLookback(bars, howManySwings, UseAll, description);

            bars.Cache[description] = _AdaptiveLookback;
            return(_AdaptiveLookback);
        }