I’m encountering an issue in NinjaTrader where I’m trying to get the names of all configured share services, particularly for Telegram, but I’m getting an error saying that Globals does not contain the definition ShareServices.
Here is the relevant code:
<code>else if (State == State.Configure)
// Get the names of all Telegram share services
telegramServiceNames = Globals.ShareServices
.Where(s => s.Name.ToLower().Contains("telegram"))
if (telegramServiceNames.Count > 0 && string.IsNullOrEmpty(SelectedServiceName))
SelectedServiceName = telegramServiceNames[0];
// Get the names of all accounts
accountNames = Account.All.Select(a => a.Name).ToList();
if (accountNames.Count > 0 && string.IsNullOrEmpty(SelectedAccountName))
SelectedAccountName = accountNames[0];
else if (State == State.DataLoaded)
// Find the selected share service
selectedTelegramService = Globals.ShareServices.FirstOrDefault(s => s.Name == SelectedServiceName);
// Find the selected account
selectedAccount = Account.All.FirstOrDefault(a => a.Name == SelectedAccountName);
if (selectedAccount != null)
selectedAccount.ExecutionUpdate += OnExecutionUpdate;
<code>else if (State == State.Configure)
{
// Get the names of all Telegram share services
telegramServiceNames = Globals.ShareServices
.Where(s => s.Name.ToLower().Contains("telegram"))
.Select(s => s.Name)
.ToList();
if (telegramServiceNames.Count > 0 && string.IsNullOrEmpty(SelectedServiceName))
{
SelectedServiceName = telegramServiceNames[0];
}
// Get the names of all accounts
accountNames = Account.All.Select(a => a.Name).ToList();
if (accountNames.Count > 0 && string.IsNullOrEmpty(SelectedAccountName))
{
SelectedAccountName = accountNames[0];
}
}
else if (State == State.DataLoaded)
{
// Find the selected share service
selectedTelegramService = Globals.ShareServices.FirstOrDefault(s => s.Name == SelectedServiceName);
// Find the selected account
selectedAccount = Account.All.FirstOrDefault(a => a.Name == SelectedAccountName);
if (selectedAccount != null)
{
selectedAccount.ExecutionUpdate += OnExecutionUpdate;
}
}
</code>
else if (State == State.Configure)
{
// Get the names of all Telegram share services
telegramServiceNames = Globals.ShareServices
.Where(s => s.Name.ToLower().Contains("telegram"))
.Select(s => s.Name)
.ToList();
if (telegramServiceNames.Count > 0 && string.IsNullOrEmpty(SelectedServiceName))
{
SelectedServiceName = telegramServiceNames[0];
}
// Get the names of all accounts
accountNames = Account.All.Select(a => a.Name).ToList();
if (accountNames.Count > 0 && string.IsNullOrEmpty(SelectedAccountName))
{
SelectedAccountName = accountNames[0];
}
}
else if (State == State.DataLoaded)
{
// Find the selected share service
selectedTelegramService = Globals.ShareServices.FirstOrDefault(s => s.Name == SelectedServiceName);
// Find the selected account
selectedAccount = Account.All.FirstOrDefault(a => a.Name == SelectedAccountName);
if (selectedAccount != null)
{
selectedAccount.ExecutionUpdate += OnExecutionUpdate;
}
}
When attempting to get the names of all share services configured by the user, I receive an error stating that Globals does not contain the definition ShareServices. How can I retrieve all the share service names in my indicator for NinjaTrader 8?