FastQuant.BarFactoryItem.OnData C# (CSharp) Method

OnData() protected method

protected OnData ( DataObject obj ) : void
obj DataObject
return void
        protected virtual void OnData(DataObject obj)
        {
            var tick = obj as Tick;
            if (this.bar == null)
            {
                // new bar begins!
                this.bar = new Bar
                {
                    InstrumentId = tick.InstrumentId,
                    Type = this.barType,
                    Size = this.barSize,
                    OpenDateTime = GetBarOpenDateTime(obj),
                    DateTime = this.GetDataObjectDateTime(obj, ClockType.Local),
                    Open = tick.Price,
                    High = tick.Price,
                    Low = tick.Price,
                    Close = tick.Price,
                    Volume = tick.Size,
                    Status = BarStatus.Open
                };
                this.factory.Framework.EventServer.OnEvent(this.bar);
            }
            else
            {
                // update it!
                if (tick.Price > this.bar.High)
                    this.bar.High = tick.Price;
                if (tick.Price < this.bar.Low)
                    this.bar.Low = tick.Price;
                this.bar.Close = tick.Price;
                this.bar.Volume += tick.Size;
                this.bar.DateTime = GetDataObjectDateTime(obj, ClockType.Local);
            }
            ++this.bar.N;
        }