コード例 #1
0
        public override void Populate()
        {
            TimeSeries source              = Parameters[0].AsTimeSeries;
            Int32      leftBars            = Parameters[1].AsInt;
            Double     leftReversalAmount  = Parameters[2].AsDouble;
            Int32      rightBars           = Parameters[3].AsInt;
            Double     rightReversalAmount = Parameters[4].AsDouble;
            Double     equalPriceThreshold = Parameters[5].AsDouble;
            bool       percentMode         = Parameters[6].AsBoolean;
            bool       setLeftSwings       = Parameters[7].AsBoolean;
            bool       setOuterSwings      = Parameters[8].AsBoolean;
            bool       setSteppedSeries    = Parameters[9].AsBoolean;

            DateTimes = source.DateTimes;
            int period = Math.Max(leftBars, rightBars);

            if (period > DateTimes.Count)
            {
                period = DateTimes.Count;
            }
            if (DateTimes.Count < period || period <= 0)
            {
                return;
            }

            Values = SwingHi.Series(source, leftBars, leftReversalAmount, rightBars, rightReversalAmount, equalPriceThreshold, percentMode, setLeftSwings, setOuterSwings, setSteppedSeries).Values;
        }
コード例 #2
0
        public static SwingHi Series(TimeSeries ds, int leftBars, double leftThreshold, int rightBars, double rightThreshold, double equalPriceFloat, bool percentMode, bool returnLeftSwing, bool returnOuterSwings, bool steppedSeries)
        {
            string key = CacheKey("SwingHi", leftBars, leftThreshold, rightBars, rightThreshold, equalPriceFloat, percentMode, returnLeftSwing, returnOuterSwings, steppedSeries);

            if (ds.Cache.ContainsKey(key))
            {
                return((SwingHi)ds.Cache[key]);
            }
            SwingHi swingHi = new SwingHi(ds, leftBars, leftThreshold, rightBars, rightThreshold, equalPriceFloat, percentMode, returnLeftSwing, returnOuterSwings, steppedSeries);

            ds.Cache[key] = swingHi;
            return(swingHi);
        }