Пример #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < KCperiod || CurrentBar < KCATRperiod)
            {
                return;
            }


            ZeroLine.Set(0);
//			BBbandTop.Set		(110);
//			BBbandBottom.Set    (-110);
//
//			KCohcTop.Set		(110);
//			KColcBot.Set		(-110);

            Values[13].Set(60);
            Values[14].Set(-60);


            // SMI plots calculations

            double min_low  = MIN(Low, percentKLength)[0];
            double max_high = MAX(High, percentKLength)[0];

            rel_diff.Set(Close[0] - (max_high + min_low) / 2);
            diff.Set(max_high - min_low);

            double avgrel  = EMA(EMA(rel_diff, percentDLength), percentDLength)[0];
            double avgdiff = EMA(EMA(diff, percentDLength), percentDLength)[0];

            smi.Set(avgrel / (avgdiff / 2) * 100);                    // PROBABLY SHOULD BE LOWER CASE DUE TO @SMI.cs
            AvgSMI.Set(EMA(smi, percentDLength)[0]);


            // end SMI plot calcs



            // BBband (not plotting) calculations

            double smaValue    = SMA(BBperiod)[0];
            double stdDevValue = StdDev(BBperiod)[0];

// probably have to make new plot names or change bottom indicator names

            bbupper.Set(smaValue + bBdevi * stdDevValue);
            bbmiddle.Set(smaValue);
            bblower.Set(smaValue - bBdevi * stdDevValue);


//			if (showBB)
//			{	BBUpper.Set (bbupper);
//				BBMiddle.Set (bbmiddle);
//				BBLower.Set (bblower);	}
//			else
//			{	BBUpper.Reset();
//				BBMiddle.Reset();
//				BBLower.Reset();	}


            // end BBband (not plotting) calculations

            //  KeltnerChannell calculations

            double kcAvg    = SMA(KCperiod)[0];
            double atrValue = ATR(KCATRperiod)[0];

            // probably have to make new plot names or change bottom indicator names

            kcmiddle.Set(kcAvg);
            kcupper.Set(kcAvg + (KCoffset * atrValue));
            kclower.Set(kcAvg - (KCoffset * atrValue));

//			if (showKC)
//			{	KCUpper.Set (kcupper);
//				KCMiddle.Set (kcmiddle);
//				KCLower.Set (kclower);	}
//			else
//			{	KCUpper.Reset();
//				KCMiddle.Reset();
//				KCLower.Reset();	}



            //  end KeltnerChannell calculations

            // SMI color changer

            if (smi[0] > smi[1])
            {
                PlotColors[0][0] = Color.Lime;
            }
//			if ( smi[0] < smi[1] )
            else
            {
                PlotColors[0][0] = Color.DeepPink;
            }
//			else
//				{ PlotColors[0][0] = Color.Yellow; }

            // end SMI color changer

            //  SMI/AvgSMIBAR color change

            if (smi[0] > 0.0)
            {
                if (smi[0] > AvgSMI[0])
                {
                    PlotColors[1][0] = Color.Cyan;
                }
                else if (smi[0] < AvgSMI[0])
                {
                    PlotColors[1][0] = Color.BlueViolet;
                }
                else
                {
                    PlotColors[1][0] = Color.PaleGreen;
                }
            }
            if (smi[0] < 0.0)
            {
                if (smi[0] < AvgSMI[0])
                {
                    PlotColors[1][0] = Color.Red;
                }
                else if (smi[0] > AvgSMI[0])
                {
                    PlotColors[1][0] = Color.Gold;
                }
                else
                {
                    PlotColors[1][0] = Color.Pink;
                }
            }

            // end SMI/AvgSMI BAR color change

            // Zero line signal color changer    plot 2                       // could change to BoolSeries pinch = this

            if (bbupper[0] > kcupper[0] && bblower[0] < kclower[0])                  //   CHANGED 2013 12 20 - - removed =sign   (was >= and <=)    (now > and < only)
            {
                PlotColors[2][0] = Color.LimeGreen;
                BackColor        = Color.Empty;
            }
            else
            {
                PlotColors[2][0] = Color.Maroon;
                BackColor        = Color.FromArgb(80, 0, 0);
            }

            // end Zero line signal color change

            // CloseAboveMean CloseBelowMean

            if ((bbupper[0] < kcupper[0]) && (bblower[0] > kclower[0]) && (Close[0] > bbmiddle[0]))
            {
                PlotColors[13][0] = Color.Cyan;
            }
            else if (((bbupper[0] <= kcupper[0]) || (bblower[0] >= kclower[0])) &&                                         // includes incomplete pinches
                     (Close[0] >= bbmiddle[0]))
            {
                PlotColors[13][0] = Color.Turquoise;
            }
            else
            {
                PlotColors[13][0] = Color.Transparent;
            }

            if ((bbupper[0] < kcupper[0]) && (bblower[0] > kclower[0]) && (Close[0] < bbmiddle[0]))
            {
                PlotColors[14][0] = Color.Gold;
            }
            else if (((bbupper[0] <= kcupper[0]) || (bblower[0] >= kclower[0])) &&                                       // includes incomplete pinches
                     (Close[0] <= bbmiddle[0]))
            {
                PlotColors[14][0] = Color.Orange;
            }

            else
            {
                PlotColors[14][0] = Color.Transparent;
            }

            // BBbandTop and BBbandBottom outside Keltner signal   plots 3 top and 4 bottom

//			if ( bbupper[0] >= kcupper[0] )
//				{ PlotColors[3][0] = Color.LimeGreen; }
//				else
//				{ PlotColors[3][0] = Color.Maroon; }
//			if ( bblower[0] <= kclower[0] )
//				{ PlotColors[4][0] = Color.LimeGreen; }
//				else
//				{ PlotColors[4][0] = Color.Maroon; }


            // end BBbandTop and BBbandBottom outside Keltner signal


            // CLOSE ABOVE KC || CLOSE BELOW KC               used to be HC > upper and LC < lower changed to just CLOSES
// changed it to H n C above and L n C below

//			if (  Close[0] > kcupper[0] )                   // High[0] > kcupper[0] &&
//				{ PlotColors[11][0] = Color.LimeGreen; }
//				else
//				{ PlotColors[11][0]= Color.Transparent;}
//			if ( Close[0] < kclower[0] )                    // Low[0] < kclower[0] &&
//				{ PlotColors[12][0]=  Color.Red;}
//				else
//				{ PlotColors[12][0]= Color.Transparent;}



            // end OPEN HIGH AND CLOSE ABOVE KC || OPEN LOW AND CLOSE BELOW KC
            // END main indiator calcs BBSbywes


// divergence calcs

            // percent Bar Complete - added to avoid divergence calcs checking every f*****g tic and also to allow something other than OnFirstTickOfBar because it didn't work - much
            // divergence calcs now happen only once - once percentBarComplete has been satisfied



            if (CurrentBar > BBperiod)
            {
                if (Bars.PercentComplete >= PercentBarComplete)            //&& lastBar != CurrentBar)    ///   percentBarComplete counter calculates divergence once after bar has built up to or through PercentBarComplete value
                {
                    // Check CCI indicator for Divergence with Price data


                    /*-------------------------------------------------------------------------------------------------------------
                    *                        Determine LAST PEAK in the SMI Line, record values for it and previous peak
                    *  -------------------------------------------------------------------------------------------------------------*/

                    //Only Look for Peaks in SMI Line

                    if (smi[0] < smi[1] && smi[1] > smi[2])               //  two lower b4 peak // && smi[2] > smi[3])
                    {
                        //Only take peaks that are above smi value of 5

                        if (smi[1] > 9.9999)                             // using even micro momentums of 9.99999
                        {
                            //	Print("----------------------------------- ");
                            //	Print("TestPeak= "+TestPeaksmi);

                            ThirdPeaksmi     = PrevPeaksmi;
                            ThirdPeakPrice   = PrevPeakPrice;
                            ThirdPeakBar     = PrevPeakBar;
                            ThirdPeakBarsAgo = (CurrentBar - ThirdPeakBar);

                            PrevPeaksmi     = LastPeaksmi;
                            PrevPeakPrice   = LastPeakPrice;
                            PrevPeakBar     = LastPeakBar;
                            PrevPeakBarsAgo = (CurrentBar - PrevPeakBar);

                            LastPeaksmi     = smi[1];
                            LastPeakPrice   = High[1];
                            LastPeakBar     = CurrentBar - 1;
                            LastPeakBarsAgo = 1;

                            //	DrawVerticalLine("smi_Peak"+CurrentBar,1,Color.Chartreuse,DashStyle.Dash,1);  // Draws a vertical line on Indicator at Peaks

//						Print(" ");
//						Print("----------------------------------- ");
//						Print(Time[0]);
//						Print("CurrentBar= "+ CurrentBar );
//						Print("Peak in smi ");
//						Print("LastPeakPrice= "+LastPeakPrice);
//						Print("PrevPeakPrice="+ PrevPeakPrice);
//						Print("ThirdPeakPrice="+ ThirdPeakPrice);
//						Print("LastPeaksmi= "+LastPeaksmi);
//						Print("PrevPeaksmi="+ PrevPeaksmi);
//						Print("ThirdPeaksmi="+ ThirdPeaksmi);
//						Print("Bars to PrevPeak="+ PrevPeakBarsAgo);
//						Print("Bars to ThirdPeak="+ ThirdPeakBarsAgo);


                            // Check for regular divergence in Peaks on  smi line

                            if (LastPeakPrice >= PrevPeakPrice && LastPeaksmi <= PrevPeaksmi)
                            {
                                DrawLine("PSMI1" + CurrentBar.ToString(), false, PrevPeakBarsAgo, PrevPeakPrice + (SignalOffset * TickSize), 1, LastPeakPrice + (SignalOffset * TickSize), Color.OrangeRed, DashStyle.Dot, 3);
                            }
                            else
                            {
                                RemoveDrawObject("PSMI1" + CurrentBar);
                            }

                            //		DrawLine("PSMI2"+CurrentBar.ToString(),false,PrevPeakBarsAgo,PrevPeaksmi,1,LastPeaksmi,Color.White,DashStyle.Dash,2);

                            // Check for 1 to 3 point Divergence

                            if (LastPeakPrice >= ThirdPeakPrice && LastPeaksmi <= ThirdPeaksmi)
                            {
                                DrawLine("PSMI3" + CurrentBar.ToString(), false, ThirdPeakBarsAgo, ThirdPeakPrice + (SignalOffset * TickSize), 1, LastPeakPrice + (SignalOffset * TickSize), Color.OrangeRed, DashStyle.Dash, 3);
                            }
                            else
                            {
                                RemoveDrawObject("PSMI3" + CurrentBar);
                            }
                            //			DrawLine("PSMI4"+CurrentBar.ToString(),false,ThirdPeakBarsAgo,ThirdPeaksmi,PrevPeakBarsAgo,PrevPeaksmi,Color.White,DashStyle.Dash,2);

                            //  ONE TO THREE DRAWLINE IS MESSED UP
                            //  SO I CHANGED LastPeakBarsAgo to a "1" like it was in CCIcolorV4Diver
                        }
                    }              //ends + side of calcs

                    /*------------------------------------------------------------------------------------------------------------------
                     *              Determine LAST VALLEY in smi Line, record values for it
                     * -------------------------------------------------------------------------------------------------------------------*/

                    // Look For Valleys in smi Line

                    if (smi[0] > smi[1] && smi[1] < smi[2])              // two higher b4 valley   //  && smi[2] < smi[3])
                    {
                        // Only take valleys that are below smi-5

                        if (smi[1] < -9.9999)                                     // same... putting in 25 to catch larger waves   I'M USING 20				{
                        {
                            ThirdValsmi     = PrevValsmi;
                            ThirdValPrice   = PrevValPrice;
                            ThirdValBar     = PrevValBar;
                            ThirdValBarsAgo = (CurrentBar - ThirdValBar);

                            PrevValsmi     = LastValsmi;
                            PrevValPrice   = LastValPrice;
                            PrevValBar     = LastValBar;
                            PrevValBarsAgo = (CurrentBar - PrevValBar);

                            LastValsmi     = smi[1];
                            LastValPrice   = Low[1];
                            LastValBar     = CurrentBar - 1;
                            LastValBarsAgo = 1;


                            //	DrawVerticalLine("smi_Val"+CurrentBar,1,Color.Red,DashStyle.Dash,1);  // draw a vertical line on Indicator at Valleys

                            /*	Print("----------------------------------- ");
                             *      Print(Time[0]);
                             *      Print("Valley in smi ");
                             *      Print(" ");
                             *      Print("LastValPrice="+ LastValPrice);
                             *      Print("PrevValPrice="+ PrevValPrice);
                             *      Print("ThirdValPrice="+ ThirdValPrice);
                             *      Print("LastValsmi="+ LastValsmi);
                             *      Print("PrevValsmi="+ PrevValsmi);
                             *      Print("ThirdValsmi="+ ThirdValsmi);
                             *      Print("Bars to Last Valley smi="+ (CurrentBar - LastValBar));
                             *      Print("Bars to Prev Valley smi="+ (CurrentBar - PrevValBar));
                             *      Print("Bars to Third Valley smi="+ (CurrentBar - ThirdValBar));
                             */

                            // Test for Divergence between LastVal and PrevVal
                            if (LastValPrice <= PrevValPrice && LastValsmi >= PrevValsmi)
                            {
                                DrawLine("VSMI1" + CurrentBar.ToString(), false, PrevValBarsAgo, PrevValPrice - (SignalOffset * TickSize), 1, LastValPrice - (SignalOffset * TickSize), Color.LimeGreen, DashStyle.Dot, 3);
                            }
                            else
                            {
                                RemoveDrawObject("VSMI1" + CurrentBar);
                            }
                            //			DrawLine("VSMI2"+CurrentBar.ToString(),false,PrevValBarsAgo,PrevValsmi,1,LastValsmi,Color.White,DashStyle.Dash,2);

                            // Check for 3 Point Divergence in valleys

                            if (LastValPrice <= ThirdValPrice && LastValsmi >= ThirdValsmi)
                            {
                                DrawLine("VSMI3" + CurrentBar.ToString(), false, ThirdValBarsAgo, ThirdValPrice - (SignalOffset * TickSize), 1, LastValPrice - (SignalOffset * TickSize), Color.LimeGreen, DashStyle.Dash, 3);
                            }
                            else
                            {
                                RemoveDrawObject("VSMI3" + CurrentBar);
                            }

                            //			DrawLine("VSMI4"+CurrentBar.ToString(),false,ThirdValBarsAgo,ThirdValsmi,PrevValBarsAgo,PrevValsmi,Color.White,DashStyle.Dash,2);
                        }
                    } //ends the (-) side of calcs
                    //lastBar = CurrentBar;
                }     //ends percentBarComplete counter
            }         //end divergence calcs
        }             // END OnBarUpdate() calcs
Пример #2
0
        protected override void OnBarUpdate()
        {
            double macdValue = BMACD[0];

            BBMACD.Set(macdValue);
            BBMACDLine.Set(macdValue);
            BBMACDFrame.Set(macdValue);
            double avg = BMACD.Avg[0];

            Average.Set(avg);
            ZeroLine.Set(0);
            double stdDevValue = SDBB[0];

            Upper.Set(avg + StdDevNumber * stdDevValue);
            Lower.Set(avg - StdDevNumber * stdDevValue);

            if (Rising(BBMACD))
            {
                if (macdValue > avg + StdDevNumber * stdDevValue)
                {
                    PlotColors[0][0] = DotsUpOutside;
                }
                else
                {
                    PlotColors[0][0] = DotsUpInside;
                }
            }
            else
            {
                if (macdValue < avg - StdDevNumber * stdDevValue)
                {
                    PlotColors[0][0] = DotsDownOutside;
                }
                else
                {
                    PlotColors[0][0] = DotsDownInside;
                }
            }
            if (BBMACD[0] > 0)
            {
                PlotColors[5][0] = ZeroPositive;
                if (CurrentBar != 0 && BBMACD[1] <= 0)
                {
                    MACDCross.Set(0);
                }
                else
                {
                    MACDCross.Reset();
                }
            }
            else
            {
                PlotColors[5][0] = ZeroNegative;
                if (CurrentBar != 0 && BBMACD[1] > 0)
                {
                    MACDCross.Set(0);
                }
                else
                {
                    MACDCross.Reset();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (!init)
            {
                BMACD   = MACD(Input, fast, slow, smooth);
                EMAMACD = EMA(BMACD, bandperiod);
                HMAMACD = HMA(BMACD, smooth);
                SDBB    = StdDev(BMACD, bandperiod);
            }
            init = true;
            double macdValue = HMAMACD[0];            //BMACD[0];

            BBMACD.Set(macdValue);
            BBMACDLine.Set(macdValue);
            BBMACDFrame.Set(macdValue);

            //double avg = EMA(BBMACD,bandperiod)[0];
            double avg = EMAMACD[0];

            Average.Set(avg);
            ZeroLine.Set(0);

            //double stdDevValue = StdDev(BBMACD,bandperiod)[0];
            double stdDevValue = SDBB[0];

            Upper.Set(avg + StdDevNumber * stdDevValue);
            Lower.Set(avg - StdDevNumber * stdDevValue);


//			if(Rising(Average))
//				if(paintbars)
//				{
//					BarColor = bbAverageUp;
//					CandleOutlineColor = candleoutlinecolorup;
//				}
//			if(Falling(Average))
//				if(paintbars)
//				{
//					BarColor = bbAverageDn;
//					CandleOutlineColor = candleoutlinecolorup;
//				}

            if (Rising(BBMACD))
            {
                if (BBMACD[0] < Upper[0])
                {
                    PlotColors[0][0] = DotsUpInside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsUpInside;
                    }
                    updotdrawn = false;                                                 // added by TheWizard March 15, 2011
                }
                else
                {
                    PlotColors[0][0] = DotsUpOutside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsUpOutside;
                    }
                    if (drawDotOnPricePanel)                                                                          // added by TheWizard March 15, 2011
                    {
                        if (updotdrawn == false)                                                                      // added by TheWizard March 15, 2011
                        {
                            DrawDot("UpDots" + CurrentBar, true, 0, Low[0] - dotSeparation * TickSize, BBdotUpColor); // added by TheWizard March 15, 2011
                            DrawDot("UpDots2" + CurrentBar, true, 0, Low[0] - dotSeparation * (TickSize * 2), BBdotUpColor);
                            updotdrawn   = true;                                                                      // added by TheWizard March 15, 2011
                            downdotdrawn = false;                                                                     // added by TheWizard March 15, 2011
                            if (bbviolationsound)
                            {
                                if (FirstTickOfBar)
                                {
                                    PlaySound(bbviolationupsound);
                                }
                            }
                        }
                    }
                }
                if (paintbars)
                {
                    BarColor           = barcolorup;
                    CandleOutlineColor = candleoutlinecolorup;
                }
            }
            else
            {
                if (BBMACD[0] > Lower[0])
                {
                    PlotColors[0][0] = DotsDownInside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsDownInside;
                    }
                    downdotdrawn = false;                                       // added by TheWizard March 15, 2011
                }
                else
                {
                    PlotColors[0][0] = DotsDownOutside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsDownOutside;
                    }
                    if (drawDotOnPricePanel)                                                                           // added by TheWizard March 15, 2011
                    {
                        if (downdotdrawn == false)                                                                     // added by TheWizard March 15, 2011
                        {
                            DrawDot("DnDots" + CurrentBar, true, 0, High[0] + dotSeparation * TickSize, BBdotDnColor); // added by TheWizard March 15, 2011
                            DrawDot("DnDots2" + CurrentBar, true, 0, High[0] + dotSeparation * (TickSize * 2), BBdotDnColor);
                            downdotdrawn = true;                                                                       // added by TheWizard March 15, 2011
                            updotdrawn   = false;                                                                      // added by TheWizard March 15, 2011
                            if (bbviolationsound)
                            {
                                if (FirstTickOfBar)
                                {
                                    PlaySound(bbviolationdnsound);
                                }
                            }
                        }
                    }
                }
                if (paintbars)
                {
                    BarColor           = barcolordn;
                    CandleOutlineColor = candleoutlinecolordn;
                }
            }
            if (BBMACD[0] > avg)
            {
                if (conservative)
                {
                    PlotColors[2][0] = BBAverageUp;
                    if (BBMACD[0] > 0)
                    {
                        PlotColors[5][0] = ZeroPositive;
                    }
                    if (BBMACD[0] < 0)
                    {
                        PlotColors[5][0] = ZeroNegative;
                    }
                }
                else
                {
                    PlotColors[2][0] = BBAverageUp;
                    PlotColors[5][0] = ZeroPositive;
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                }
            }

            if (BBMACD[0] < avg)
            {
                if (conservative)
                {
                    PlotColors[2][0] = BBAverageDn;
                    if (BBMACD[0] > 0)
                    {
                        PlotColors[5][0] = ZeroPositive;
                    }
                    if (BBMACD[0] < 0)
                    {
                        PlotColors[5][0] = ZeroNegative;
                    }
                }
                else
                {
                    PlotColors[2][0] = BBAverageDn;
                    PlotColors[5][0] = ZeroNegative;
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                }
            }

            //PlotColors[2][0] = BBAverage;
            PlotColors[3][0] = BBUpper;
            PlotColors[4][0] = BBLower;
            PlotColors[6][0] = ZeroCross;
            PlotColors[7][0] = Connector;

            if (BBMACD[0] > 0)
            {
                if (conservative)
                {
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                }
                if (CurrentBar != 0 && BBMACD[1] <= 0)
                {
                    MACDCross.Set(0);
                    if (zerolinecrosssound)
                    {
                        if (FirstTickOfBar)
                        {
                            PlaySound(longwavfilename);
                        }
                    }
                }

                else
                {
                    MACDCross.Reset();
                }
            }
            else
            {
                if (conservative)
                {
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                }
                if (CurrentBar != 0 && BBMACD[1] > 0)
                {
                    MACDCross.Set(0);
                    if (zerolinecrosssound)
                    {
                        if (FirstTickOfBar)
                        {
                            PlaySound(shortwavfilename);
                        }
                    }
                }
                else
                {
                    MACDCross.Reset();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < bandperiod)
            {
                return;
            }

            if (!init)
            {
                BMACD   = MACD(Input, fast, slow, smooth);
                EMAMACD = EMA(BMACD, bandperiod);
                HMAMACD = HMA(BMACD, smooth);
                SDBB    = StdDev(BMACD, bandperiod);
            }
            init = true;
            double macdValue = HMAMACD[0];            //BMACD[0];

            BBMACD.Set(macdValue);
            //BBMACDLine.Set(macdValue);
            BBMACDFrame.Set(macdValue);

            //double avg = EMA(BBMACD,bandperiod)[0];
            double avg = EMAMACD[0];

            ZeroLine.Set(0);

            //double stdDevValue = StdDev(BBMACD,bandperiod)[0];
            double stdDevValue = SDBB[0];

            Upper.Set(avg + StdDevNumber * stdDevValue);
            Lower.Set(avg - StdDevNumber * stdDevValue);

            //1. Green dots, above bands, sloping up Green dot - text UP - prefer up as easy to understand
            //2. Green dots, above bands, changing to a red dot. - Cell Colour will Change (but may still say UP)
            //3. Consecutive red dots crossing down through the bands - not sure we discussed this one!!! Cell colour will change Put --- to indicate crossing down
            //4. Red dots, below bands, sloping down.Red dot - text DOWN - prefer DOWN as easy to understand
            //5. Red dots, below bands, changing to a green dot.ell Colour will Change (but may still say DOWN)
            //6. Consecutive green dots, crossing up through the bands - not sure we discussed this one!!! Cell colour will change Put +++ to indicate crossing down

            //1 & 4 - would be trending signals - don't trade against these
            //2 & 5 - would be minor alerts for consolidation or the start of direction change
            //3 & 6 - would be major alerts with direction change confirmed by dots about to break through the opposite band



            if (Rising(BBMACD))
            {
                if (BBMACD[0] < Upper[0])
                {
                    PlotColors[0][0] = DotsUpInside;
                    macdsignal       = 1;
                }
                else if ((BBMACD[1] < Upper[1]) && (BBMACD[0] > Upper[0]))
                {
                    PlotColors[0][0] = DotsUpOutside;
                    macdsignal       = 2;
                }
                else
                {
                    PlotColors[0][0] = DotsUpOutside;
                    macdsignal       = 3;
                }
            }
            else
            {
                if (BBMACD[0] > Lower[0])
                {
                    PlotColors[0][0] = DotsDownInside;
                    macdsignal       = -1;
                }
                else if ((BBMACD[1] > Lower[1]) && (BBMACD[0] < Lower[0]))
                {
                    PlotColors[0][0] = DotsDownOutside;
                    macdsignal       = -2;
                }

                else
                {
                    PlotColors[0][0] = DotsDownOutside;
                    macdsignal       = -3;
                }
            }


            Signal.Set(macdsignal);



/*
 *
 *                              if (BBMACD[0] > BBMACD[1])
 *          {
 *              PlotColors[0][0] = DotsUpOutside;
 *              if ((BBMACD[0] > Upper[0]))  //UP
 *              {
 *                  macdsignal = 1;
 *                  PlotColors[0][0] = DotsUpOutside;
 *              }
 *              else if ((BBMACD[1] < Lower[1]) && (BBMACD[0] > Lower[0]))  //UP
 *              {
 *                  macdsignal = 6;
 *                  PlotColors[0][0] = DotsDownInside;
 *              }
 *              else if ((BBMACD[1] > BBMACD[2]) && (BBMACD[0] > Lower[0]))   //UP
 *              {
 *                  macdsignal = 7;
 *                  PlotColors[0][0] = DotsUpInside;
 *              }
 *              else if ((BBMACD[1] < Upper[1]) && (BBMACD[0] > Upper[0]))    //UP
 *              {
 *                  macdsignal = 8;
 *                  PlotColors[0][0] = DotsUpOutside;
 *              }
 *          }
 *          else //(BBMACD[0] < BBMACD[1])
 *          {
 *              PlotColors[0][0] = DotsDownOutside;
 *              if ((BBMACD[0] < Lower[0]))  //DN
 *              {
 *                  macdsignal = 5;
 *                  PlotColors[0][0] = DotsDownOutside;
 *              }
 *              else if ((BBMACD[0] < BBMACD[1]))  //DN
 *              {
 *                  macdsignal = 2;
 *                  PlotColors[0][0] = DotsDownOutside;
 *              }
 *              else if ((BBMACD[1] < BBMACD[2]) && (BBMACD[0] < Upper[0]))   //DN
 *              {
 *                  macdsignal = 3;
 *                  PlotColors[0][0] = DotsDownInside;
 *              }
 *              else if ((BBMACD[1] > Lower[1]) && (BBMACD[0] < Lower[0]))    //DN
 *              {
 *                  macdsignal = 4;
 *                  PlotColors[0][0] = DotsDownOutside;
 *              }
 *          }
 */
/*
 *          if ((BBMACD[0] > BBMACD[1]) && (BBMACD[0] > Upper[0]))  //UP
 *          {
 *              macdsignal = 1;
 *              PlotColors[0][0] = DotsUpOutside;
 *          }
 *          if ((BBMACD[1] > Upper[1]) && (BBMACD[0] < BBMACD[1]))  //DN
 *          {
 *              macdsignal = 2;
 *              PlotColors[0][0] = DotsDownOutside;
 *          }
 *          if ((BBMACD[0] < BBMACD[1]) && (BBMACD[1] < BBMACD[2]) && (BBMACD[0] < Upper[0]))   //DN
 *          {
 *              macdsignal = 3;
 *              PlotColors[0][0] = DotsDownInside;
 *          }
 *          if ((BBMACD[0] < BBMACD[1]) && (BBMACD[1] > Lower[1]) && (BBMACD[0] < Lower[0]))    //DN
 *          {
 *              macdsignal = 4;
 *              PlotColors[0][0] = DotsDownOutside;
 *          }
 *
 *          if ((BBMACD[0] < BBMACD[1]) && (BBMACD[0] < Lower[0]))  //DN
 *          {
 *              macdsignal = 5;
 *              PlotColors[0][0] = DotsDownOutside;
 *          }
 *          if ((BBMACD[1] < Lower[1]) && (BBMACD[0] > BBMACD[1]))  //UP
 *          {
 *              macdsignal = 6;
 *              PlotColors[0][0] = DotsDownInside;
 *          }
 *          if ((BBMACD[0] > BBMACD[1]) && (BBMACD[1] > BBMACD[2]) && (BBMACD[0] > Lower[0]))   //UP
 *          {
 *              macdsignal = 7;
 *              PlotColors[0][0] = DotsUpInside;
 *          }
 *          if ((BBMACD[0] > BBMACD[1]) && (BBMACD[1] < Upper[1]) && (BBMACD[0] > Upper[0]))    //UP
 *          {
 *              macdsignal = 8;
 *              PlotColors[0][0] = DotsUpOutside;
 *          }
 */


            /////PlotColors[2][0] = BBUpper;
            /////PlotColors[3][0] = BBLower;
            /////PlotColors[4][0] = SignalCol;
            /////PlotColors[5][0] = ZeroCol;
        }