What's its doc/ control? Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
What's the control for the ChartTrader position change tracker?
Collapse
X
-
Hello Chelsea and thanks for the reference. I found your other reference with demo about the Windows inspect tool
Customizing Chart Trader - NT8
thanks but I'm not sure what the automationID is used for. Can you please explain? Thanks!
Following my previous code below, I used it as "label" in
PHP Code:ChartControl.Dispatcher.InvokeAsync((Action)(() => { PnLDisplay = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlPnLDisplay") as NinjaTrader.Gui.Tools.PositionDisplay); }));
but what does it mean?
I adjusted my other indicator code using QuantitySelector in the Toolbar
BuyMktSellMktHotkeysQS
From
PHP Code:namespace NinjaTrader.NinjaScript.Indicators { public class BuyMktSellMktHotkeysQS : Indicator { private Account myAccount; // QS Define a Chart object to refer to the chart on which the indicator resides private Chart chartWindow; NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector = null; // QS private bool Is_ToolBar_Controls_Added; protected override void OnStateChange() { NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector; if (State == State.SetDefaults) { AccountName = "Sim101"; } else if (State == State.Configure) { } else if (State == State.Historical) { //Call the custom addButtonToToolbar method in State.Historical to ensure it is only done when applied to a chart // -- not when loaded in the Indicators window if (!Is_ToolBar_Controls_Added) Add_Controls_To_Toolbar(); } else if (State == State.DataLoaded) { ChartControl.Dispatcher.InvokeAsync((Action)(() => { quantitySelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown); })); } } else if (State == State.Terminated) { DisposeCleanUp(); } #region Add Controls To Toolbar private void Add_Controls_To_Toolbar() { // Use this.Dispatcher to ensure code is executed on the proper thread ChartControl.Dispatcher.InvokeAsync((Action)(() => { //Obtain the Chart on which the indicator is configured chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart; if (chartWindow == null) { Print("chartWindow == null"); return; } quantitySelector = new NinjaTrader.Gui.Tools.QuantityUpDown(); //quantitySelector.ValueChanged += On_quantitySelector_ValueChanged; quantitySelector.PreviewKeyDown += On_quantitySelector_PreviewKeyDown; chartWindow.MainMenu.Add(quantitySelector); Is_ToolBar_Controls_Added = true; })); } #endregion #region DisposeCleanUp private void DisposeCleanUp() { //ChartWindow Null Check if (chartWindow != null) { //Dispatcher used to Assure Executed on UI Thread ChartControl.Dispatcher.InvokeAsync((Action)(() => { if( quantitySelector != null ) chartWindow.MainMenu.Remove(quantitySelector); })); } } #endregion }
To
PHP Code:namespace NinjaTrader.NinjaScript.Indicators { public class BuyMktSellMktHotkeysQS : Indicator { private Account myAccount; // QS Define a Chart object to refer to the chart on which the indicator resides private Chart chartWindow; NinjaTrader.Gui.Tools.PositionDisplay PnLDisplay = null; // QS private bool Is_ToolBar_Controls_Added; protected override void OnStateChange() { NinjaTrader.Gui.Tools.PositionDisplay PnLDisplay; if (State == State.SetDefaults) { AccountName = "Sim101"; } else if (State == State.Configure) { } else if (State == State.Historical) { //Call the custom addButtonToToolbar method in State.Historical to ensure it is only done when applied to a chart // -- not when loaded in the Indicators window if (!Is_ToolBar_Controls_Added) Add_Controls_To_Toolbar(); } else if (State == State.DataLoaded) { ChartControl.Dispatcher.InvokeAsync((Action)(() => { PnLDisplay = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlPnLDisplay") as NinjaTrader.Gui.Tools.PositionDisplay); })); } } else if (State == State.Terminated) { DisposeCleanUp(); } #region Add Controls To Toolbar private void Add_Controls_To_Toolbar() { // Use this.Dispatcher to ensure code is executed on the proper thread ChartControl.Dispatcher.InvokeAsync((Action)(() => { //Obtain the Chart on which the indicator is configured chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart; if (chartWindow == null) { Print("chartWindow == null"); return; } PnLDisplay = new NinjaTrader.Gui.Tools.PositionDisplay(); chartWindow.MainMenu.Add(PnLDisplay); Is_ToolBar_Controls_Added = true; })); } #endregion #region DisposeCleanUp private void DisposeCleanUp() { //ChartWindow Null Check if (chartWindow != null) { //Dispatcher used to Assure Executed on UI Thread ChartControl.Dispatcher.InvokeAsync((Action)(() => { if( PnLDisplay != null ) chartWindow.MainMenu.Remove(PnLDisplay); })); } } #endregion [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))] public string AccountName { get; set; } } }
I'll test and be baclk asa. Thanks!Last edited by PaulMohn; 03-16-2022, 01:20 PM.
Comment
-
Chelsea, I got it in the Toolbar as this
How can i get only the PnL one and remove the Flat and Entry ones?
Or if possible get them to display laterally?
Or if possible get them smaller to fit the normal ToolBar size? Thanks!
Also how to get to display the orders PnL? I tested submitting an order and it display in the chart trader but not in the ToolBar.Last edited by PaulMohn; 03-16-2022, 01:18 PM.
Comment
-
Hello PaulMohn,
Thats how the object comes. It wasn't designed for a toolbar, it was designed to fit in Chart Trader.
Manipulating this may be possible, however this would be outside of the realm of our support.
This thread will remain open for any community members that would like to assist.
You could alternatively use regular WPF controls like stackpanels and textboxes and populate those with information from the Account.Chelsea B.NinjaTrader Customer Service
Comment
-
Ok thanks. Do you have simple samples and doc about stackpanels and textboxes about specifically getting the PnL box into the toolbar (not on the chart if possible) ?
Also what is the doc reference of the DisplayPnL Above? i'd like to check if there's more info about getting the PnL box only.
Also any reason why the PnL doesn't display? Thanks!
Comment
-
Hello PaulMohn,
There is one sample you may find helpful.
https://ninjatrader.com/support/help...ui)-modifi.htm
StackPanels and TextBlocks are C# which made by Microsoft. Please refer to the Microsoft documentation.
There is no support using a PositionDisplay. This would be undocumented.
Below is a link to the help guide with the only documented NinjaTrader Controls that are supported by our support to use.
https://ninjatrader.com/support/help...8/controls.htm
For anything else, this would be your custom C# code for you to use at your discretion.Last edited by NinjaTrader_ChelseaB; 03-16-2022, 02:28 PM.Chelsea B.NinjaTrader Customer Service
Comment
-
Thanks. Is there an equivalent for Indicators of the position_getunrealizedprofitloss ?
If yes can we display it in the toolbar? Thanks!
Comment
-
Hello PaulMohn,
The Account.Positions[instrument index].GetUnrealizedProfitLoss().
https://ninjatrader.com/support/help...ns_account.htm
A script that uses this.
Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
331 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
550 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment