/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            double value1 = 0.0;
            double value2 = 0.0;

            o.Update();
            h.Update();
            l.Update();
            c.Update();

            for (int i = 0; i < len; ++i)
            {
                value1 += (c.filtered(i) - o.filtered(i));
                value2 += (h.filtered(i) - l.filtered(i));
            }

            if (value2 != 0.0)
            {
                unsmoothed.Set(100.0 * value1 / value2);
            }
            else
            {
                if ((CurrentBar > 1) && unsmoothed.ContainsValue(1))
                {
                    unsmoothed.Set(unsmoothed[1]);
                }
                else
                {
                    unsmoothed.Set(0);
                }
            }

            if (weightma == null)
            {
                weightma = WMA(unsmoothed, smoothing);
                expma    = EMA(weightma.Value, trigger);
            }

            ECO.Set(weightma[0]);
            TriggerLine.Set(expma[0]);
            Histogram.Set(weightma[0] - expma[0]);
        }
Esempio n. 2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            var ed = extdat.getExtraData(0, Bars, CurrentBar);

            if (ed == null)
            {
                return;
            }

            if (CurrentBar != lastSeenBar)
            {
                for (int i = 0; i < 4; ++i)
                {
                    pol[i] = ol[i];         // remember previous bar value...
                    phl[i] = hl[i];
                    pll[i] = ll[i];
                    pcl[i] = cl[i];
                }
                lastSeenBar = CurrentBar;
            }


            // update all the Laguerre numbers....
            ol[0] = (1 - gamma) * ed.dOpen + gamma * pol[0];
            hl[0] = (1 - gamma) * ed.dHigh + gamma * phl[0];
            ll[0] = (1 - gamma) * ed.dLow + gamma * pll[0];
            cl[0] = (1 - gamma) * ed.dClose + gamma * pcl[0];
            for (int i = 1; i < 4; ++i)
            {
                ol[i] = -gamma * ol[i - 1] + pol[i - 1] + gamma * pol[i];
                hl[i] = -gamma * hl[i - 1] + phl[i - 1] + gamma * phl[i];
                ll[i] = -gamma * ll[i - 1] + pll[i - 1] + gamma * pll[i];
                cl[i] = -gamma * cl[i - 1] + pcl[i - 1] + gamma * pcl[i];
            }

            double value1 = 0.0;
            double value2 = 0.0;

            for (int i = 0; i < 4; ++i)
            {
                value1 += (cl[i] - ol[i]);
                value2 += (hl[i] - ll[i]);
            }

            if (value2 != 0.0)
            {
                unsmoothed.Set(100.0 * value1 / value2);
            }
            else
            {
                if ((CurrentBar > 1) && unsmoothed.ContainsValue(1))
                {
                    unsmoothed.Set(unsmoothed[1]);
                }
                else
                {
                    unsmoothed.Set(0);
                }
            }

            if (weightma == null)
            {
                weightma = WMA(unsmoothed, smoothing);
                expma    = EMA(weightma.Value, trigger);
            }

            ECO.Set(weightma[0]);
            TriggerLine.Set(expma[0]);
            Histogram.Set(weightma[0] - expma[0]);
        }