/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCreateSession_Click(object sender, EventArgs e)
        {
            if (symbolSelectControl.SelectedSymbols.Count == 0)
            {
                MessageBox.Show("No symbol selected.");
                return;
            }

            ComponentId?orderExecuteId = null;
            int         compatibility  = 0;

            if ((radioButtonSimulationTrading.Checked || radioButtonLiveTrading.Checked) &&
                comboBoxOrderExecutionSources.SelectedIndex < _orderExecutionSourcesIds.Count)
            {
                orderExecuteId = _orderExecutionSourcesIds[comboBoxOrderExecutionSources.SelectedIndex];
                compatibility  = _orderExecutionSourcesCompatibilities[comboBoxOrderExecutionSources.SelectedIndex];
            }

            string operationResultMessage;

            DataSessionInfo?sessionInfo = Host.GetSymbolDataSessionInfo(symbolSelectControl.SelectedDataSourceId.Value,
                                                                        symbolSelectControl.SelectedSymbols[0]);

            if (sessionInfo.HasValue == false)
            {
                MessageBox.Show("Failed to initiate session for this symbol.");
                return;
            }

            if (_host.GetExpertSession(sessionInfo.Value) != null)
            {
                MessageBox.Show("Session for this symbol/source already exists.");
                return;
            }

            if (compatibility < 100 && radioButtonLiveTrading.Checked)
            {
                if (MessageBox.Show("You are creating a live session with order execution provider [" + orderExecuteId.Value.Name + "], that has low compatilibity level with selected data source. It is likely this is not the default order execution provider for this data source." + Environment.NewLine + Environment.NewLine + "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }
            }

            PlatformExpertSession session = _host.CreateExpertSession(sessionInfo.Value, symbolSelectControl.SelectedDataSourceId.Value,
                                                                      orderExecuteId, radioButtonSimulationTrading.Checked, out operationResultMessage);

            if (session == null || _host.RegisterExpertSession(session) == false)
            {
                MessageBox.Show("Failed to create session [" + operationResultMessage + "].", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // TODO: add support for tick dataDelivery.
                TimeSpan period = TimeSpan.FromHours(1);

                if (symbolSelectControl.SelectedPeriod.HasValue)
                {
                    period = symbolSelectControl.SelectedPeriod.Value;
                }
                else
                {
                    if (GeneralHelper.EnumerableContains <TimeSpan>(session.DataProvider.AvailableDataBarProviderPeriods, period) == false)
                    {// We can not use 1hour because it is not available.
                        if (session.DataProvider.AvailableDataBarProviderPeriods.Length > 0)
                        {
                            period = session.DataProvider.AvailableDataBarProviderPeriods[0];
                        }
                        else
                        {
                            SystemMonitor.OperationWarning("Failed to establish period for session, going for default (1 hour) although not marked as available.");
                        }
                    }
                }

                if (session.DataProvider.ObtainDataBarProvider(period) == false)
                {
                    SystemMonitor.OperationError("Failed to obtain data bar provide for period [" + period.ToString() + "].");
                }

                if (SessionCreatedEvent != null)
                {
                    SessionCreatedEvent();
                }
            }

            this.Hide();
        }