/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { bars.update(); var maval = smoother.next(Input[0]); band.update(Input[0], maval); BandHigh.Set(bandSmoother1.next(band.UpperBand)); BandLow.Set(bandSmoother2.next(band.LowerBand)); MidLine.Set(maval); }
protected override void OnBarUpdate() { double RSI_value = RSI(this.RSIPeriod, 1)[0]; this._RSI_List.Set(RSI_value); double PRICE_value = SMA(this._RSI_List, this.PricePeriod)[0]; PriceLine.Set(PRICE_value); double SIGNAL_value = SMA(this._RSI_List, this.SignalPeriod)[0]; SignalLine.Set(SIGNAL_value); double AVG_value = SMA(this._RSI_List, this.BandPeriod)[0]; Average.Set(AVG_value); MidLine.Set(50); double stdDevValue = StdDev(this._RSI_List, this.BandPeriod)[0]; Upper.Set(AVG_value + this.StdDevNumber * stdDevValue); Lower.Set(AVG_value - this.StdDevNumber * stdDevValue); PlotColors[0][0] = this.Main; PlotColors[1][0] = this.Signal; PlotColors[2][0] = this.BBAverage; PlotColors[3][0] = this.BBUpper; PlotColors[4][0] = this.BBLower; if (AVG_value > 50) { PlotColors[5][0] = this.MidPositive; } else { PlotColors[5][0] = this.MidNegative; } Plots[0].PenStyle = this.Dash0Style; Plots[0].Pen.Width = this.Plot0Width; Plots[1].PenStyle = this.Dash1Style; Plots[1].Pen.Width = this.Plot1Width; Plots[2].PenStyle = this.Dash2Style; Plots[2].Pen.Width = this.Plot2Width; Plots[3].PenStyle = this.Dash3Style; Plots[3].Pen.Width = this.Plot3Width; Plots[4].PenStyle = this.Dash3Style; Plots[4].Pen.Width = this.Plot3Width; Plots[5].PenStyle = this.Dash3Style; Plots[5].Pen.Width = this.Plot3Width; }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar > prevBar) { // NEW BAR PROCESSING prevBar = CurrentBar; if (barsToDisplay > 0 && prevBar > barsToDisplay) { UpperBand.Reset(barsToDisplay); LowerBand.Reset(barsToDisplay); MidLine.Reset(barsToDisplay); } // midline var gv = newGaussVal(prevMedian, avgTotal); if (++curGaussIdx > poles) { curGaussIdx = 0; } avg[curGaussIdx] = gv; avgTotal = calcAvgTotal(); prevMedian = -1; // runerr devSum = cdevSum; devs[curIdx] = cnewVal; if (++curIdx >= devLen) { curIdx = 0; } // smooth bands ubema1 = cubema1; ubema2 = cubema2; ubema3 = cubema3; lbema1 = clbema1; lbema2 = clbema2; lbema3 = clbema3; } if (prevMedian != Median[0]) { prevMedian = Median[0]; // midline... var ngv = newGaussVal(prevMedian, avgTotal); // runerr... cnewVal = prevMedian - ngv; cnewVal = cnewVal * cnewVal; cdevSum = devSum - devs[curIdx] + cnewVal; var stdDev = numDevs * Math.Sqrt(Math.Max(cdevSum / devLen, 1e-10)); // smooth bands... cubema1 = ubema1 + balpha1 * (ngv + stdDev - ubema1); cubema2 = ubema2 + balpha2 * (ngv + stdDev - ubema2); cubema3 = ubema3 + balpha3 * (cubema2 + cubema2 - cubema1 - ubema3); clbema1 = lbema1 + balpha1 * (ngv - stdDev - lbema1); clbema2 = lbema2 + balpha2 * (ngv - stdDev - lbema2); clbema3 = lbema3 + balpha3 * (clbema2 + clbema2 - clbema1 - lbema3); UpperBand.Set(cubema3); LowerBand.Set(clbema3); MidLine.Set(ngv); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar > prevBar) { prevBar = CurrentBar; if (CurrentBar == 0) { cema1 = Median[0]; cema2 = cema1; cema3 = cema1; cubema1 = cema1; cubema2 = cema1; cubema3 = cema1; clbema1 = cema1; clbema2 = cema1; clbema3 = cema1; cnewVal = 0.0; cdevSum = 0.0; } // midline ema1 = cema1; ema2 = cema2; ema3 = cema3; prevMedian = -1; // runerr devSum = cdevSum; devs[curIdx] = cnewVal; if (++curIdx >= devLen) { curIdx = 0; } // smooth bands ubema1 = cubema1; ubema2 = cubema2; ubema3 = cubema3; lbema1 = clbema1; lbema2 = clbema2; lbema3 = clbema3; } if (prevMedian != Median[0]) { prevMedian = Median[0]; // midline... cema1 = ema1 + alpha1 * (prevMedian - ema1); cema2 = ema2 + alpha2 * (prevMedian - ema2); cema3 = ema3 + alpha3 * (cema2 + cema2 - cema1 - ema3); // runerr... cnewVal = prevMedian - cema3; cnewVal = cnewVal * cnewVal; cdevSum = devSum - devs[curIdx] + cnewVal; var stdDev = numDevs * Math.Sqrt(Math.Max(cdevSum / devLen, 1e-10)); // smooth bands... cubema1 = ubema1 + balpha1 * (cema3 + stdDev - ubema1); cubema2 = ubema2 + balpha2 * (cema3 + stdDev - ubema2); cubema3 = ubema3 + balpha3 * (cubema2 + cubema2 - cubema1 - ubema3); clbema1 = lbema1 + balpha1 * (cema3 - stdDev - lbema1); clbema2 = lbema2 + balpha2 * (cema3 - stdDev - lbema2); clbema3 = lbema3 + balpha3 * (clbema2 + clbema2 - clbema1 - lbema3); UpperBand.Set(cubema3); LowerBand.Set(clbema3); MidLine.Set(cema3); } }