Пример #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            var ed = extdat.getExtraData(0, Bars, CurrentBar);

            if (CurrentBar != lastBarSeen)
            {
                memGotNewBar();
                lastBarSeen = CurrentBar;

                if (ed != null)
                {
                    prevUp = ed.UpTicks;
                    prevDn = ed.DnTicks;
                    for (double p = Low[0]; p <= High[0]; p += TickSize)
                    {
                        long upt; long dnt;
                        ed.getUpDnTicksAtPrice(TickSize, p, out upt, out dnt);
                        if (upt > 0)
                        {
                            memInsertDeltaUp(p, upt);
                        }
                        if (dnt > 0)
                        {
                            memInsertDeltaDn(p, dnt);
                        }
                    }
                }
            }
            else
            {
                if (ed != null)
                {
                    if (ed.UpTicks > prevUp)
                    {
                        memInsertDeltaUp(Close[0], ed.UpTicks - prevUp);
                        prevUp = ed.UpTicks;
                    }
                    if (ed.DnTicks > prevDn)
                    {
                        memInsertDeltaDn(Close[0], ed.DnTicks - prevDn);
                        prevDn = ed.DnTicks;
                    }
                }
            }


            double totalUp, totalDn, currentUp, currentDn;

            memPressureForBar(out totalUp, out currentUp, out totalDn, out currentDn);

            if (compactForm)
            {
                if (totalUp > totalDn)
                {
                    totalUp -= totalDn; totalDn = 0;
                }
                else
                {
                    totalDn -= totalUp; totalUp = 0;
                }
            }

            Buyers.Set(totalUp);
            Sellers.Set(-totalDn);
            BuyersThisBar.Set(currentUp);
            SellersThisBar.Set(-currentDn);
        }