Esempio n. 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 = SwingLo.Series(source, leftBars, leftReversalAmount, rightBars, rightReversalAmount, equalPriceThreshold, percentMode, setLeftSwings, setOuterSwings, setSteppedSeries).Values;
        }
Esempio n. 2
0
        public static SwingLo Series(TimeSeries ds, int leftBars, double leftThreshold, int rightBars, double rightThreshold, double equalPriceFloat, bool percentMode, bool returnLeftSwing, bool returnOuterSwings, bool steppedSeries)
        {
            string key = CacheKey("SwingLo", leftBars, leftThreshold, rightBars, rightThreshold, equalPriceFloat, percentMode, returnLeftSwing, returnOuterSwings, steppedSeries);

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

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