//TOGGLE FOR TEMPORARY TESTING
        private void RunBacktestButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            UnbindInitializationModels();
            UnbindReportModels();

            _backtest.Clear();
            _activityModel.Status = "Backtest started.";
            var tickDataGroups = BacktestingTickFileControl.GetSelectedFilePaths();

            _activityModel.NumberTestsToRun     = tickDataGroups.Count;
            _activityModel.NumberTestsCompleted = 0;

            foreach (var _tickDataGroup in tickDataGroups)
            {
                var _backtestingModel = new BacktestingModel();
                _backtestingModel.CacheWait = _backtestingConfigurationModel.CacheWait;
                var _reportModel = new BatchReportModel(_backtestingModel, _activityModel /*, updatePlots*/);
                var info         = TickFileNameInfo.GetTickFileInfoFromLongName(_tickDataGroup.First());
                _reportModel.ReportName = "Y:" + info.Year.ToString() + ",M:" + info.Month.ToString() + ",D:" + info.Day.ToString();

                _backtest.AddRun(_backtestingModel, _reportModel);

                _reportModel.RegisterDispatcher(DispatchableType.Fill, FillsTab.Dispatcher);
                _reportModel.RegisterDispatcher(DispatchableType.Indicator, IndicatorTab.Dispatcher);
                _reportModel.RegisterDispatcher(DispatchableType.Message, MessagesTab.Dispatcher);
                _reportModel.RegisterDispatcher(DispatchableType.Order, OrdersTab.Dispatcher);
                _reportModel.RegisterDispatcher(DispatchableType.Plot, BacktestPlotter.Dispatcher);
                _reportModel.RegisterDispatcher(DispatchableType.Position, PositionTab.Dispatcher);

                BindInitializationModels();

                _backtestingModel.LoadResponse(_backtestingConfigurationModel.GetFreshResponseInstance());
                _backtestingModel.LoadTickData(_tickDataGroup);
                _backtestingModel.Play(_backtestingConfigurationModel.SelectedPlayToValue);
            }

            Task.Factory.StartNew(() =>
            {
                _activityModel.AllRunsCompleted.WaitOne();
                if (_backtest.BacktestReports.Any())
                {
                    _backtest.SelectedReport = _backtest.BacktestReports.First();
                    BindStatisticsModels("Results");
                }
            });
        }
        private void RunBacktestButton_Click2(object sender, System.Windows.RoutedEventArgs e)
        {
            UnbindInitializationModels();
            UnbindReportModels();

            _backtest2.Clear();
            _activityModel.Status = "Backtest started.";
            var tickDataGroups = BacktestingTickFileControl.GetSelectedFilePaths();

            _activityModel.NumberTestsToRun     = tickDataGroups.Count;
            _activityModel.NumberTestsCompleted = 0;

            Task.Factory.StartNew(() =>
            {
                _activityModel.AllRunsCompleted.WaitOne();
                if (_backtest2.BacktestReports.Any())
                {
                    _backtest2.SelectedReport = _backtest2.BacktestReports.First();
                    BindStatisticsModels2("Results");
                }
            });

            foreach (var _tickDataGroup in tickDataGroups)
            {
                var hubConfig = new HubConfigurationModel(HubType.Local);

                var brokerConfig = new BrokerConfigurationModel(BrokerType.Sim);
                brokerConfig.PlayToValue       = _backtestingConfigurationModel.SelectedPlayToValue;
                brokerConfig.SimUseBidAskFills = false;
                brokerConfig.TickFiles         = _tickDataGroup;
                brokerConfig.SubscriptionList  = new List <byte[]> {
                    EventType.Basket, EventType.CancelOrder, EventType.Order
                };

                var responseConfig = new ResponseConfigurationModel();
                responseConfig.ResponseList.Add(_backtestingConfigurationModel.GetFreshResponseInstance());
                responseConfig.SubscriptionList = new List <byte[]> {
                    EventType.CancelOrderAck, EventType.Fill, EventType.Message, EventType.OrderAck, EventType.Tick
                };

                var reportConfig = new ReportConfigurationModel();
                reportConfig.Type             = ReportType.Batch;
                reportConfig.ActivityInstance = _activityModel;
                var info = TickFileNameInfo.GetTickFileInfoFromLongName(_tickDataGroup.First());
                reportConfig.ReportName       = "Y:" + info.Year.ToString() + ",M:" + info.Month.ToString() + ",D:" + info.Day.ToString();
                reportConfig.SubscriptionList = new List <byte[]> {
                    EventType.ChartLabel, EventType.Fill, EventType.Indicator, EventType.Message, EventType.Order, EventType.ServiceTransition, EventType.Tick
                };
                reportConfig.FilterMode = true;

                var sessionModel = new SessionModel(hubConfig, brokerConfig, responseConfig, reportConfig);

                _backtest2.AddRun(sessionModel);

                sessionModel.Reporter.RegisterDispatcher(EventType.Fill, FillsTab.Dispatcher);
                sessionModel.Reporter.RegisterDispatcher(EventType.Indicator, IndicatorTab.Dispatcher);
                sessionModel.Reporter.RegisterDispatcher(EventType.Message, MessagesTab.Dispatcher);
                sessionModel.Reporter.RegisterDispatcher(EventType.Order, OrdersTab.Dispatcher);
                sessionModel.Reporter.RegisterDispatcher(EventType.Plot, BacktestPlotter.Dispatcher);
                sessionModel.Reporter.RegisterDispatcher(EventType.Position, PositionTab.Dispatcher);
            }

            BindInitializationModels2();
            _backtest2.Start(0);
        }