Esempio n. 1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            Dexp.Set(dexp[0]);
            var devs = dexp.StdDev * stdDevs;

            LowerBand.Set(Dexp[0] - devs);
            UpperBand.Set(Dexp[0] + devs);
        }
Esempio n. 2
0
 protected override void OnBarUpdate()
 {
     #region Indicator formula
     PriceSeries.Set((High[0] + Low[0] + Close[0]) / 3);
     JMA.Set(JurikJMA(PriceSeries, 7, -25)[0]);
     TR = High[0] - Low[0];
     if (CurrentBar > 0)
     {
         TR = Math.Max(TR, Math.Max(High[0] - Close[1], Close[1] - Low[0]));
     }
     trueRange.Set(TR);
     bandSize = Band_width * SMA(trueRange, 200)[Math.Min(CurrentBar, Band_delay)];
     DWMA     = WMA(WMA(PriceSeries, Band_len), Band_len)[Math.Min(CurrentBar, Band_delay)];
     UpperBand.Set(DWMA + bandSize);
     LowerBand.Set(DWMA - bandSize);
     #endregion
 }
Esempio n. 3
0
        /// <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);
            }
        }
Esempio n. 4
0
        /// <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);
            }
        }