Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to Identify the Connection Name for an Account on Chart Trader
Collapse
X
-
How to Identify the Connection Name for an Account on Chart Trader
In NinjaScript, how can I determine which connection (e,g, Barchart.com, Coinbase, E-Signal, External, IQFeed, Kinetick, Rithmic for NinaTrader Brokerage, TD AMERITRADE, Interactive Brokers etc) is linked to the account on Chart Trader?Tags: None
-
Hello, thanks for writing in. The chart trader selected account object can be accessed with this snippet:
Code:ChartControl.Dispatcher.InvokeAsync((Action)(() => { NinjaTrader.Gui.Tools.AccountSelector accSelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector); Print(accSelector.SelectedAccount); }));
-
trader-ap You should do it like this.
Code:#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators { public class TestChartTraderAccountConnection : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "Test ChartTrader Account Connection"; IsOverlay = true; } else if (State == State.Transition) { Account ChartTraderAccount = null; ChartControl.Dispatcher.Invoke((Action)(() => { NinjaTrader.Gui.Tools.AccountSelector AccountSelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector); ChartTraderAccount = (AccountSelector != null) ? AccountSelector.SelectedAccount : null; })); Connection ChartTraderAccountConnection = (ChartTraderAccount != null) ? ChartTraderAccount.Connection : null; string ChartTraderAccountConnectionName = (ChartTraderAccountConnection != null) ? ChartTraderAccountConnection.Options.Name : ""; Draw.TextFixed(this, "EXAMPLE", "Account " + ChartTraderAccount + " on connection " + ChartTraderAccountConnectionName, TextPosition.Center, Brushes.Blue, new SimpleFont(), Brushes.Black, Brushes.White, 100); } } } }
- Likes 3
Comment
-
Hi,
Im trying the version QuantKey_Bruce posted. If I have several accounts in the dropdown menu 'Account' and toggle between them, I would like the text to update with the chosen Account Name. Atm It only update names after Reloading chart.
Is this doable?
Br. MK
Comment
-
NinjaTrader support or a user may be able to advise if there is an event you can subscribe to for the dropdown changing on the chart trader. If there is not, I would suggest that you set up a dispatcher timer and check once a second or so to see if they changed the dropdown, and only if there is a change, update the text.
Comment
-
Hi mkivi, there is a SelectionChanged event built into the AccountSelector control:
https://ninjatrader.com/support/help...ntselector.htm
Updated link: [https://]ninjatrader[dot]com/support/helpGuides/nt8/NT%20HelpGuide%20English[dot]html?accountselector[dot]htm
Please make sure to remove the brackets and replace 'dot' with a period.
Last edited by NinjaTrader_LuisH; 07-26-2023, 11:20 AM.
Comment
-
Thanks @QuantKey_Bruce for showing how to do this. For anyone else, I have slightly amended the example code to also include the Connection Brand Name. This name cannot be modified by the end user and allows the indicator to know whether the connection is "Interactive Brokers" or "Rithmic for NinjaTrader Brokerage" or another brokers. Note the connection name can be renamed by the end user.
Code:#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators.Tools { public class TestChartTraderAccountConnection : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "Test ChartTrader Account Connection"; IsOverlay = true; } else if (State == State.Transition) { Account ChartTraderAccount = null; ChartControl.Dispatcher.Invoke((Action)(() => { NinjaTrader.Gui.Tools.AccountSelector AccountSelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector); ChartTraderAccount = (AccountSelector != null) ? AccountSelector.SelectedAccount : null; })); Connection ChartTraderAccountConnection = (ChartTraderAccount != null) ? ChartTraderAccount.Connection : null; string ChartTraderAccountConnectionName = (ChartTraderAccountConnection != null) ? ChartTraderAccountConnection.Options.Name : ""; Draw.TextFixed(this, "EXAMPLE", "Account " + ChartTraderAccount + " on connection " + ChartTraderAccountConnectionName + " with brand name " + ChartTraderAccount.Connection.Options.BrandName, TextPosition.Center, Brushes.Blue, new SimpleFont(), Brushes.Black, Brushes.White, 100); } } } }
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment