public void ReceiveCandle(sCandle pCandle)
        {
            Candle = pCandle;

            ATR.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            BB.ReceiveTick(pCandle.C);
            CCI.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            Derivatives.ReceiveTick(pCandle.C);
            EMA.ReceiveTick(pCandle.C);
            FMA.ReceiveTick(pCandle.C);
            HMA.ReceiveTick(pCandle.C);
            MACD.ReceiveTick(pCandle.C);
            Momemtum.ReceiveTick(pCandle.C);
            RSI.ReceiveTick(pCandle.C);
            Renko.ReceiveTick(pCandle.C);
            SMA.ReceiveTick(pCandle.C);
            STARCBands.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            STDDEV.ReceiveTick(pCandle.C);
            Slope.ReceiveTick(pCandle.C);
            StochRSI.ReceiveTick(pCandle.C);
            Stochastics.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            Stub.ReceiveTick(pCandle.C);
            Trend.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            TrueRange.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
            WMA.ReceiveTick(pCandle.C);
        }
        // CandleBuilders call this function when registered with them
        // and a new candle is built
        // one distinguished calling CandleBuilder by handle in candle and period
        public override void ReceiveCandle(sCandle pCandle, int pPeriod, string pCBTitle)
        {
            if ((pPeriod == Minutes) && (pCBTitle == "cbx"))
            {
                HMA.ReceiveTick(pCandle.C);
                FMA.ReceiveTick(pCandle.C);
                CCI.ReceiveTick(pCandle.O, pCandle.H, pCandle.L, pCandle.C);
                //BBands.ReceiveTick(pCandle.C);
                //StochRSI.ReceiveTick(pCandle.C);

                if (HMA.Value() != 0)
                {
                    Derivatives.ReceiveTick(HMA.Value());
                    BBands.ReceiveTick(HMA.Value());
                    StochRSI.ReceiveTick(HMA.Value());
                }

                if ((cbx.candlecount > 3) && (Derivatives.isPrimed()) && (StochRSI.isPrimed()))
                {
                    double deriv2;
                    double deriv1;

                    Derivatives.Value(out deriv1, out deriv2);

                    Deriv1.Add(deriv1);
                    Deriv2.Add(deriv2);

                    if (Deriv2.tickcount > 2)
                    {
                        DecisionFunction();
                    }
                }
            }
        }
        public override void ReceiveCandle(sCandle pCandle, int pPeriod, string pCBTitle)
        {
            if ((pPeriod == Minutes) && (pCBTitle == "cbx"))
            {
                double TP = (pCandle.H + pCandle.L + pCandle.C) / 3;

                Candle = pCandle;

                BBands.ReceiveTick(pCandle.C);
                HMA.ReceiveTick(TP);

                if (BBands.isPrimed() && HMA.isPrimed())
                {
                    DecisionFunction();
                }
            }
        }
        public static void TestBBands()
        {
            iBollingerBands BB;

            BB = new iBollingerBands(10, -1);
            BB = new iBollingerBands(20, -1);
            BB = new iBollingerBands(50, -1);

            BB = new iBollingerBands(21, -1);


            double[] val = { 6.92, 6.89, 6.82, 6.82, 6.83, 6.79, 6.75, 6.71, 6.71, 6.66, 6.59, 6.56, 6.59, 6.56, 6.61, 6.68, 6.65, 6.68, 6.54, 6.49, 6.42 };

            for (int i = 0; i < val.GetUpperBound(0) + 1; i++)
            {
                BB.ReceiveTick(val[i]);
            }

            double BP, MA, BM, pb, bw;

            BB.Value(out BP, out MA, out BM, out pb, out bw);

            if (Math.Abs(MA - 6.68) < 0.01)
            {
                Framework.Logger(2, "MA Returns correct value: " + MA);
            }

            if (Math.Abs(BP - 6.94) < 0.01)
            {
                Framework.Logger(2, "BP Returns correct value: " + BP);
            }

            if (Math.Abs(BM - 6.41) < 0.01)
            {
                Framework.Logger(2, "BM Returns correct value: " + BM);
            }
        }