//populate
        public override void Populate()
        {
            TimeSeries ds      = Parameters[0].AsTimeSeries;
            Int32      period1 = Parameters[1].AsInt;
            Int32      period2 = Parameters[2].AsInt;

            DateTimes = ds.DateTimes;
            int period = Math.Max(period1, period2);

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


            var FirstValidValue = Math.Max(period1, period2);

            if (FirstValidValue > ds.Count || FirstValidValue < 0)
            {
                FirstValidValue = ds.Count;
            }
            if (ds.Count < Math.Max(period1, period2))
            {
                return;
            }

            sMACD   smacd = new sMACD(ds, period1, period2);
            FastSMA sma   = new FastSMA(smacd, 9);

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                Values[bar] = sma[bar];
            }
        }
        //populate
        public override void Populate()
        {
            TimeSeries ds      = Parameters[0].AsTimeSeries;
            Int32      period1 = Parameters[1].AsInt;
            Int32      period2 = Parameters[2].AsInt;
            Int32      period3 = Parameters[3].AsInt;

            DateTimes = ds.DateTimes;
            var period = new List <int> {
                period1, period2, period3
            }.Max();

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

            var FirstValidValue = period;

            if (FirstValidValue > ds.Count || FirstValidValue < 0)
            {
                FirstValidValue = ds.Count;
            }
            if (ds.Count < Math.Max(Math.Max(period1, period2), period3))
            {
                return;
            }
            if (period3 <= 1)
            {
                return;
            }

            sMACD smacd = new sMACD(ds, period1, period2);
            int   XY    = period1 * period2;
            int   XZ    = period1 * period3;
            int   YZ    = period2 * period3;
            int   XYZ   = period1 * period2 * period3;

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                Values[bar] = (smacd[bar] * (XYZ - XY) -
                               XYZ * new FastSMA(smacd, period3)[bar] -
                               ds[period1 + 1] * (YZ - period2) +
                               ds[period2 + 1] * (XZ - period1) +
                               XY * smacd[period3 + 1]) / (XZ - YZ - period1 + period2);
            }
        }