void CreateSessionPane(bool trading) { if (listViewQuotes.SelectedItems.Count < 1 || Component.Delivery == null || Component.DataSourceId.HasValue == false) { return; } ListViewItem item = listViewQuotes.SelectedItems[0]; LocalExpertHost host = new LocalExpertHost(item.Text, typeof(ManualTradeExpert)); Component.Platform.RegisterComponent(host); RuntimeDataSessionInformation info = Component.Delivery.GetSymbolRuntimeSessionInformation((Symbol)item.Tag); if (info == null) { SystemMonitor.OperationError("Failed to obtain symbol session, operation can not be performed."); MessageBox.Show("Failed to obtain symbol session, operation can not be performed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string operationResultMessage; ComponentId?tradeSourceId = null; if (trading) { SortedDictionary <int, List <ComponentId> > compatibleExecutioners = Component.GetCompatibleOrderExecutionSources(Component.DataSourceId.Value, info.Info.Symbol, SourceTypeEnum.Live | SourceTypeEnum.OrderExecution); if (compatibleExecutioners.Count == 0 || compatibleExecutioners[GeneralHelper.EnumerableFirstThrows <int>(compatibleExecutioners.Keys)].Count == 0) { MessageBox.Show("Failed to find order execution source for this symbol. Trading can not be initiated."); return; } tradeSourceId = compatibleExecutioners[GeneralHelper.EnumerableFirstThrows <int>(compatibleExecutioners.Keys)][0]; } PlatformExpertSession session = host.CreateExpertSession(info.Info, Component.DataSourceId.Value, tradeSourceId, false, out operationResultMessage); if (session == null) { SystemMonitor.OperationError(operationResultMessage); MessageBox.Show(operationResultMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (host.RegisterExpertSession(session)) { // Try to run a 1hour chart, or if not, any chart available. bool oneHourFound = false; foreach (TimeSpan span in session.DataProvider.AvailableDataBarProviderPeriods) { if (span == TimeSpan.FromHours(1)) { session.DataProvider.ObtainDataBarProvider(TimeSpan.FromHours(1)); oneHourFound = true; break; } } if (oneHourFound == false && session.DataProvider.AvailableDataBarProviderPeriods.Length > 0) { session.DataProvider.ObtainDataBarProvider(session.DataProvider.AvailableDataBarProviderPeriods[0]); } // Allow the pending control requests to be created and performed before floating it. this.BeginInvoke(new GeneralHelper.GenericDelegate <LocalExpertHost>(SetControlFloat), host); } else { SystemMonitor.OperationError("Failed to register session."); MessageBox.Show("Failed to register session.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }