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(); } } }
/// <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(); } } }
/// <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; }