public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowSpikes != null) { hashCode = hashCode * 59 + ShowSpikes.GetHashCode(); } if (SpikeSides != null) { hashCode = hashCode * 59 + SpikeSides.GetHashCode(); } if (SpikeThickness != null) { hashCode = hashCode * 59 + SpikeThickness.GetHashCode(); } if (SpikeColor != null) { hashCode = hashCode * 59 + SpikeColor.GetHashCode(); } if (ShowBackground != null) { hashCode = hashCode * 59 + ShowBackground.GetHashCode(); } if (BackgroundColor != null) { hashCode = hashCode * 59 + BackgroundColor.GetHashCode(); } if (ShowAxesLabels != null) { hashCode = hashCode * 59 + ShowAxesLabels.GetHashCode(); } if (Color != null) { hashCode = hashCode * 59 + Color.GetHashCode(); } if (CategoryOrder != null) { hashCode = hashCode * 59 + CategoryOrder.GetHashCode(); } if (CategoryArray != null) { hashCode = hashCode * 59 + CategoryArray.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (AutoRange != null) { hashCode = hashCode * 59 + AutoRange.GetHashCode(); } if (RangeMode != null) { hashCode = hashCode * 59 + RangeMode.GetHashCode(); } if (Range != null) { hashCode = hashCode * 59 + Range.GetHashCode(); } if (TickMode != null) { hashCode = hashCode * 59 + TickMode.GetHashCode(); } if (NTicks != null) { hashCode = hashCode * 59 + NTicks.GetHashCode(); } if (Tick0 != null) { hashCode = hashCode * 59 + Tick0.GetHashCode(); } if (DTick != null) { hashCode = hashCode * 59 + DTick.GetHashCode(); } if (TickVals != null) { hashCode = hashCode * 59 + TickVals.GetHashCode(); } if (TickText != null) { hashCode = hashCode * 59 + TickText.GetHashCode(); } if (Ticks != null) { hashCode = hashCode * 59 + Ticks.GetHashCode(); } if (Mirror != null) { hashCode = hashCode * 59 + Mirror.GetHashCode(); } if (TickleN != null) { hashCode = hashCode * 59 + TickleN.GetHashCode(); } if (TickWidth != null) { hashCode = hashCode * 59 + TickWidth.GetHashCode(); } if (TickColor != null) { hashCode = hashCode * 59 + TickColor.GetHashCode(); } if (ShowTickLabels != null) { hashCode = hashCode * 59 + ShowTickLabels.GetHashCode(); } if (TickFont != null) { hashCode = hashCode * 59 + TickFont.GetHashCode(); } if (TickAngle != null) { hashCode = hashCode * 59 + TickAngle.GetHashCode(); } if (TickPrefix != null) { hashCode = hashCode * 59 + TickPrefix.GetHashCode(); } if (ShowTickPrefix != null) { hashCode = hashCode * 59 + ShowTickPrefix.GetHashCode(); } if (TickSuffix != null) { hashCode = hashCode * 59 + TickSuffix.GetHashCode(); } if (ShowTickSuffix != null) { hashCode = hashCode * 59 + ShowTickSuffix.GetHashCode(); } if (ShowExponent != null) { hashCode = hashCode * 59 + ShowExponent.GetHashCode(); } if (ExponentFormat != null) { hashCode = hashCode * 59 + ExponentFormat.GetHashCode(); } if (SeparateThousands != null) { hashCode = hashCode * 59 + SeparateThousands.GetHashCode(); } if (TickFormat != null) { hashCode = hashCode * 59 + TickFormat.GetHashCode(); } if (TickFormatStops != null) { hashCode = hashCode * 59 + TickFormatStops.GetHashCode(); } if (HoverFormat != null) { hashCode = hashCode * 59 + HoverFormat.GetHashCode(); } if (ShowLine != null) { hashCode = hashCode * 59 + ShowLine.GetHashCode(); } if (LineColor != null) { hashCode = hashCode * 59 + LineColor.GetHashCode(); } if (LineWidth != null) { hashCode = hashCode * 59 + LineWidth.GetHashCode(); } if (ShowGrid != null) { hashCode = hashCode * 59 + ShowGrid.GetHashCode(); } if (GridColor != null) { hashCode = hashCode * 59 + GridColor.GetHashCode(); } if (GridWidth != null) { hashCode = hashCode * 59 + GridWidth.GetHashCode(); } if (ZeroLine != null) { hashCode = hashCode * 59 + ZeroLine.GetHashCode(); } if (ZeroLineColor != null) { hashCode = hashCode * 59 + ZeroLineColor.GetHashCode(); } if (ZeroLineWidth != null) { hashCode = hashCode * 59 + ZeroLineWidth.GetHashCode(); } if (Calendar != null) { hashCode = hashCode * 59 + Calendar.GetHashCode(); } if (CategoryArraySrc != null) { hashCode = hashCode * 59 + CategoryArraySrc.GetHashCode(); } if (TickValsSrc != null) { hashCode = hashCode * 59 + TickValsSrc.GetHashCode(); } if (TickTextSrc != null) { hashCode = hashCode * 59 + TickTextSrc.GetHashCode(); } return(hashCode); } }
public bool Equals([AllowNull] XAxis other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) && (ShowSpikes == other.ShowSpikes && ShowSpikes != null && other.ShowSpikes != null && ShowSpikes.Equals(other.ShowSpikes)) && (SpikeSides == other.SpikeSides && SpikeSides != null && other.SpikeSides != null && SpikeSides.Equals(other.SpikeSides)) && (SpikeThickness == other.SpikeThickness && SpikeThickness != null && other.SpikeThickness != null && SpikeThickness.Equals(other.SpikeThickness)) && (SpikeColor == other.SpikeColor && SpikeColor != null && other.SpikeColor != null && SpikeColor.Equals(other.SpikeColor)) && (ShowBackground == other.ShowBackground && ShowBackground != null && other.ShowBackground != null && ShowBackground.Equals(other.ShowBackground)) && (BackgroundColor == other.BackgroundColor && BackgroundColor != null && other.BackgroundColor != null && BackgroundColor.Equals(other.BackgroundColor)) && (ShowAxesLabels == other.ShowAxesLabels && ShowAxesLabels != null && other.ShowAxesLabels != null && ShowAxesLabels.Equals(other.ShowAxesLabels)) && (Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color)) && (CategoryOrder == other.CategoryOrder && CategoryOrder != null && other.CategoryOrder != null && CategoryOrder.Equals(other.CategoryOrder)) && (Equals(CategoryArray, other.CategoryArray) || CategoryArray != null && other.CategoryArray != null && CategoryArray.SequenceEqual(other.CategoryArray)) && (Title == other.Title && Title != null && other.Title != null && Title.Equals(other.Title)) && (Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) && (AutoRange == other.AutoRange && AutoRange != null && other.AutoRange != null && AutoRange.Equals(other.AutoRange)) && (RangeMode == other.RangeMode && RangeMode != null && other.RangeMode != null && RangeMode.Equals(other.RangeMode)) && (Equals(Range, other.Range) || Range != null && other.Range != null && Range.SequenceEqual(other.Range)) && (TickMode == other.TickMode && TickMode != null && other.TickMode != null && TickMode.Equals(other.TickMode)) && (NTicks == other.NTicks && NTicks != null && other.NTicks != null && NTicks.Equals(other.NTicks)) && (Tick0 == other.Tick0 && Tick0 != null && other.Tick0 != null && Tick0.Equals(other.Tick0)) && (DTick == other.DTick && DTick != null && other.DTick != null && DTick.Equals(other.DTick)) && (Equals(TickVals, other.TickVals) || TickVals != null && other.TickVals != null && TickVals.SequenceEqual(other.TickVals)) && (Equals(TickText, other.TickText) || TickText != null && other.TickText != null && TickText.SequenceEqual(other.TickText)) && (Ticks == other.Ticks && Ticks != null && other.Ticks != null && Ticks.Equals(other.Ticks)) && (Mirror == other.Mirror && Mirror != null && other.Mirror != null && Mirror.Equals(other.Mirror)) && (TickleN == other.TickleN && TickleN != null && other.TickleN != null && TickleN.Equals(other.TickleN)) && (TickWidth == other.TickWidth && TickWidth != null && other.TickWidth != null && TickWidth.Equals(other.TickWidth)) && (TickColor == other.TickColor && TickColor != null && other.TickColor != null && TickColor.Equals(other.TickColor)) && (ShowTickLabels == other.ShowTickLabels && ShowTickLabels != null && other.ShowTickLabels != null && ShowTickLabels.Equals(other.ShowTickLabels)) && (TickFont == other.TickFont && TickFont != null && other.TickFont != null && TickFont.Equals(other.TickFont)) && (TickAngle == other.TickAngle && TickAngle != null && other.TickAngle != null && TickAngle.Equals(other.TickAngle)) && (TickPrefix == other.TickPrefix && TickPrefix != null && other.TickPrefix != null && TickPrefix.Equals(other.TickPrefix)) && (ShowTickPrefix == other.ShowTickPrefix && ShowTickPrefix != null && other.ShowTickPrefix != null && ShowTickPrefix.Equals(other.ShowTickPrefix)) && (TickSuffix == other.TickSuffix && TickSuffix != null && other.TickSuffix != null && TickSuffix.Equals(other.TickSuffix)) && (ShowTickSuffix == other.ShowTickSuffix && ShowTickSuffix != null && other.ShowTickSuffix != null && ShowTickSuffix.Equals(other.ShowTickSuffix)) && (ShowExponent == other.ShowExponent && ShowExponent != null && other.ShowExponent != null && ShowExponent.Equals(other.ShowExponent)) && (ExponentFormat == other.ExponentFormat && ExponentFormat != null && other.ExponentFormat != null && ExponentFormat.Equals(other.ExponentFormat)) && (SeparateThousands == other.SeparateThousands && SeparateThousands != null && other.SeparateThousands != null && SeparateThousands.Equals(other.SeparateThousands)) && (TickFormat == other.TickFormat && TickFormat != null && other.TickFormat != null && TickFormat.Equals(other.TickFormat)) && (Equals(TickFormatStops, other.TickFormatStops) || TickFormatStops != null && other.TickFormatStops != null && TickFormatStops.SequenceEqual(other.TickFormatStops)) && (HoverFormat == other.HoverFormat && HoverFormat != null && other.HoverFormat != null && HoverFormat.Equals(other.HoverFormat)) && (ShowLine == other.ShowLine && ShowLine != null && other.ShowLine != null && ShowLine.Equals(other.ShowLine)) && (LineColor == other.LineColor && LineColor != null && other.LineColor != null && LineColor.Equals(other.LineColor)) && (LineWidth == other.LineWidth && LineWidth != null && other.LineWidth != null && LineWidth.Equals(other.LineWidth)) && (ShowGrid == other.ShowGrid && ShowGrid != null && other.ShowGrid != null && ShowGrid.Equals(other.ShowGrid)) && (GridColor == other.GridColor && GridColor != null && other.GridColor != null && GridColor.Equals(other.GridColor)) && (GridWidth == other.GridWidth && GridWidth != null && other.GridWidth != null && GridWidth.Equals(other.GridWidth)) && (ZeroLine == other.ZeroLine && ZeroLine != null && other.ZeroLine != null && ZeroLine.Equals(other.ZeroLine)) && (ZeroLineColor == other.ZeroLineColor && ZeroLineColor != null && other.ZeroLineColor != null && ZeroLineColor.Equals(other.ZeroLineColor)) && (ZeroLineWidth == other.ZeroLineWidth && ZeroLineWidth != null && other.ZeroLineWidth != null && ZeroLineWidth.Equals(other.ZeroLineWidth)) && (Calendar == other.Calendar && Calendar != null && other.Calendar != null && Calendar.Equals(other.Calendar)) && (CategoryArraySrc == other.CategoryArraySrc && CategoryArraySrc != null && other.CategoryArraySrc != null && CategoryArraySrc.Equals(other.CategoryArraySrc)) && (TickValsSrc == other.TickValsSrc && TickValsSrc != null && other.TickValsSrc != null && TickValsSrc.Equals(other.TickValsSrc)) && (TickTextSrc == other.TickTextSrc && TickTextSrc != null && other.TickTextSrc != null && TickTextSrc.Equals(other.TickTextSrc))); }
/// <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
/// <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(); } } }
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 (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; }