public bool Initialize()
        {
            lock (this)
            {
                _timeControl = new TimeControl();

                _timeControl.CanStepForward = true;
                _timeControl.CanStepBack = false;
                _timeControl.CanRestart = false;

                _timeControl.Period = _period;

                _timeControl.TotalStepsValueUpdateEvent += delegate(ITimeControl control)
                {
                    if (_sourceDataBarProvider == null)
                    {
                        return 0;
                    }

                    return _sourceDataBarProvider.BarCount;
                };

                _timeControl.CurrentStepChangedEvent += delegate(ITimeControl control)
                {
                    _step = _timeControl.CurrentStep.Value;
                };

                _timeControl.StepForwardEvent += delegate(ITimeControl control, int steps)
                {
                    if (_sourceDataBarProvider == null)
                    {
                        SystemMonitor.Warning("Current data bar provider not assigned.");
                        return true;
                    }

                    lock (this)
                    {
                        bool step = (_sourceDataBarProvider.BarCount > _timeControl.CurrentStep.Value);
                        if (step == false || steps == 0)
                        {
                            return false;
                        }
                    }

                    List<DataBar> newBars = new List<DataBar>();
                    lock (_sourceDataBarProvider)
                    {
                        ReadOnlyCollection<DataBar> barsUnsafe = _sourceDataBarProvider.BarsUnsafe;

                        for (int i = 0; i < steps && _timeControl.CurrentStep.Value + i < barsUnsafe.Count; i++)
                        {
                            newBars.Add(barsUnsafe[_timeControl.CurrentStep.Value + i]);
                        }
                    }

                    if (newBars.Count > 0)
                    {// Feed the update steps one by one.

                        foreach (DataBar bar in newBars)
                        {
                            if (DataHistoryUpdateEvent != null)
                            {// This will insert those bars in the surfaceKeeper.
                                DataHistoryUpdateEvent(this, _sessionInfo, new DataHistoryUpdate(_timeControl.Period.Value, new DataBar[] { bar }));
                            }

                            if (QuoteUpdateEvent != null)
                            {
                                QuoteUpdateEvent(this, _sessionInfo, new Quote(bar, _spreadPoints * _sessionInfo.DecimalIncrement));
                            }
                        }
                    }

                    //if (DataHistoryUpdateEvent != null)
                    //{// This will insert those bars in the surfaceKeeper.
                    //    DataHistoryUpdateEvent(this, _sessionInfo, new DataHistoryUpdate(_timeControl.Period.Value, bars));
                    //}

                    //if (QuoteUpdateEvent != null)
                    //{
                    //    QuoteUpdateEvent(this, _sessionInfo, new Quote(bars[bars.Count - 1], _spreadPoints * _sessionInfo.DecimalIncrement));
                    //}

                    return true;
                };

                _timeControl.StepToEvent += delegate(ITimeControl control, int index)
                {
                    if (_sourceDataBarProvider == null)
                    {
                        SystemMonitor.OperationWarning("Current data bar provider not assigned.");
                        return true;
                    }

                    List<DataBar> newBars = new List<DataBar>();
                    lock (this)
                    {
                        if (index <= _timeControl.CurrentStep || index > _sourceDataBarProvider.BarCount)
                        {// Step invalid.
                            SystemMonitor.OperationWarning(string.Format("Step to invalid [{0} out of {1}, current {2}].", index.ToString(), _sourceDataBarProvider.BarCount.ToString(), _timeControl.CurrentStep.Value));
                            return false;
                        }
                    }

                    lock (_sourceDataBarProvider)
                    {
                        ReadOnlyCollection<DataBar> barsUnsafe = _sourceDataBarProvider.BarsUnsafe;
                        for (int i = _timeControl.CurrentStep.Value; i < index; i++)
                        {
                            newBars.Add(barsUnsafe[i]);
                        }
                    }

                    if (newBars.Count > 0)
                    {// Feed the update steps one by one.

                        foreach (DataBar bar in newBars)
                        {
                            if (DataHistoryUpdateEvent != null)
                            {// This will insert those bars in the surfaceKeeper.
                                DataHistoryUpdateEvent(this, _sessionInfo, new DataHistoryUpdate(_timeControl.Period.Value, new DataBar[] { bar }));
                            }

                            if (QuoteUpdateEvent != null)
                            {
                                QuoteUpdateEvent(this, _sessionInfo, new Quote(bar, _spreadPoints * _sessionInfo.DecimalIncrement));
                            }
                        }
                    }

                    return true;
                };

                //_sourceDataBarProvider.DataBarHistoryUpdateEvent += new DataBarHistoryUpdateDelegate(_sourceDataBarProvider_DataBarHistoryUpdateEvent);
            }

            RestoreLastStep();

            return true;
        }
        /// <summary>
        /// One time init by passing references essential for operation.
        /// </summary>
        public bool SetInitialParameters(ISourceManager manager, ISourceDataDelivery dataDelivery)
        {
            _manager = manager;
            _dataDelivery = dataDelivery;

            _account.SetInitialParameters(_manager, this, _dataDelivery);
            _tradeEntities.SetInitialParameters(_manager, this, _dataDelivery);

            _timeControl = new TimeControl();
            _timeControl.CanStepBack = false;
            _timeControl.CanStepForward = true;
            _timeControl.CanRestart = false;
            _timeControl.TotalStepsCount = int.MaxValue;

            ChangeOperationalState(OperationalStateEnum.Initializing);

            return true;
        }