Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Modifications to chart WPF elements and tab considerations
Collapse
X
-
Hi Chelsea, your "ChartToolBarCustomMenuExample" has been a great starting point from which we can build our own personalized indicators. Any chance you can help me extend its usefulness a bit? I am stuck trying to load the same indicator on two or more tabs of the same chart window (issue: the menu icon is only visible in toolbar of first tab to which indicator is loaded). It would also be helpful to be able to load same indicator two or more times in the same tab and have a separate menu icon corresponding to each.
Thanks.
-
Hi Dougtre,
Try these files.Attached Files
- Likes 2
Leave a comment:
-
Hi kkc2015. Thanks for sharing.Originally posted by kkc2015 View PostHi Unsuitable,
It looks like you are making good progress.
Attached are a screen shot and a totally stripped down version of a button indicator (NT8), which can be imported and compiled.
If you press the Help button to make it green, when you press any other buttons, you can see the text on the bottom right of the chart, showing the pressed button. After you have loaded this indicator on the chart, you will see the column of buttons on the right side of the chart.
Good luck.
I'm getting this when trying to download the code:
Invalid File Specified
Could you please re-up the file?
Thanks a lot.
Leave a comment:
-
There are no exact NT7 to NT8 toolbars conversions.Originally posted by rcrook23 View PostHi Unsuitable would be interested to see your final result. The toolbar you had in NT7 is exactly what I'm looking for in NT8. I've tried to code something myself but I'm only a beginner coder.
thanks in advance.
NT7 Toolbar: https://ninjatraderecosystem.com/use...lbar-shortcut/
However, people have used other libraries to reproduce the same functionality;
https://ninjatraderecosystem.com/use...njaaddons-com/
https://ninjatraderecosystem.com/use...-mahtoolbar-2/
*Do note mahtoolbar calls the DrawingTool by way of hotkeys. So you may have to modify the script to match your hotkeys or use NT defaults.Last edited by Unsuitable; 10-01-2020, 03:21 PM.
Leave a comment:
-
Hi Unsuitable would be interested to see your final result. The tool bar you had in NT7 is exactly what I'm looking for in NT8. I've tried to code something myself but I'm only a beginner coder.
thanks in advance.
Leave a comment:
-
Hi kkc2015,
I started to move the buttons so that they are alongside the main menu buttons. However, the solution to programmatically remove all the buttons does not seem to work with the main menu buttons. So chartWindow.MainMenu is where all the buttons are stored. When it comes to NT natives buttons, it has a wrapper and within that wrapper, there are the NT buttons. So the only object buttons within chartWindow.MainMenu[] are my buttons.
Solutions tried
1. Creating a new list and at the time of creating the buttons, store the new buttons. RESULT: the indicator crashes
2. Tried using the UserControlCollection. RESULT: NT doesn't catch the crash so it infinite loops and I have to recover NT
3. Using a foreach loop and specifying button filter. RESULT: indicator crashes
4. Using a foreach loop and specifying Object filter and printing the elements: RESULT: Buttons + NinjaTrader.Gui.Tools.InstrumentSelector NinjaTrader.Gui.Tools.IntervalSelector + etc
HOLD YOUR HORSES, I got it. Solution 1 does work, however one needs to initialize it. So it went from thisCode:ChartControl.Dispatcher.InvokeAsync((() => { if (chartWindow != null) { //System.Windows.Controls.Button[] buttonsChartControl = {exampleButton}; //hardcoded //System.Windows.Controls.Button[] buttonsChartControl = chartWindow.MainMenu.OfType<System.Windows.Control s.Button>().ToArray(); //programmatically foreach (System.Windows.Controls.Button btn in chartWindow.MainMenu) { Print(btn.ToString()); } System.Windows.Controls.Button[] buttonsChartControl = buttonList.ToArray(); Print("ss"); for (int i = 0; i < buttonsChartControl.Count(); i++) { Print("test "); if (buttonsChartControl[i] != null) { Print("bob "); chartWindow.MainMenu.Remove(buttonsChartControl[i]); buttonsChartControl[i].Click -= OnMyButtonClick; buttonsChartControl[i] = null; buttonList.Remove(buttonsChartControl[i]); } } } }));
toCode:private List<System.Windows.Controls.Button> buttonList;
Code:private List<System.Windows.Controls.Button> buttonList; ... buttonList = new List<System.Windows.Controls.Button>();
Leave a comment:
-
Hi Unsuitable,
It looks like you are making good progress.
Attached are a screen shot and a totally stripped down version of a button indicator (NT8), which can be imported and compiled.
If you press the Help button to make it green, when you press any other buttons, you can see the text on the bottom right of the chart, showing the pressed button. After you have loaded this indicator on the chart, you will see the column of buttons on the right side of the chart.
Good luck.Last edited by kkc2015; 10-02-2020, 11:19 AM.
Leave a comment:
-
//Yeah no worries mate, I went with another button solution.Originally posted by kkc2015 View PostHi Unsuitable,
Sorry for the confusion. The file contains the codes for the buttons and the grids + other unrelated variables which were used for other indicators. It is not a complete stand alone indicator and contains other variables (with declaration deleted) and thus would not compile. The main purpose is to show 1) the frame work, 2) the actual codes for the buttons and grids and 3) where they should be placed.
You have to copy and paste only the button and grid codes, including declarations, and placed in the same sections (eg. initialize inside State.SetDefaults, State.DataLoaded, etc) of your indicator.
So this dispatcher thing is new to me, but it's a requirement and what not for buttons. In the OG code, it went through each individual button by name. For 2 buttons this solution is fine, however for 10+ buttons, repeating the same code over and over is just bad practice. Down below I've implemented a for loop that takes care of all the buttons. Does this check out? It does compile but there can be some run time errors as well.
ThanksCode:ChartControl.Dispatcher.InvokeAsync((() => { if (myGrid != null) { System.Windows.Controls.Button[] buttons = { Button1, Button2, Button3, Button4, Button5, Button6, Button7, Button8, Button9, Button10}; for (int i = 0; i < buttons.Count(); i++) { if (buttons[i] != null) { myGrid.Children.Remove(buttons[i]); buttons[i].Click -= OnMyButtonClick; buttons[i] = null; } } // if (Button1 != null) // { // myGrid.Children.Remove(Button1); // Button1.Click -= OnMyButtonClick; // Button1 = null; // } } }));
Edit: It must work cause if I remove that piece of code, it starts duplicating the buttons.Last edited by Unsuitable; 09-29-2020, 02:29 PM.
Leave a comment:
-
Hello kkc2015,
To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:- Click Tools -> Export -> NinjaScript...
- Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
- Click the 'Export' button
- Enter a unique name for the file in the value for 'File name:'
- Choose a save location -> click Save
- Click OK to clear the export location message
- (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
http://ninjatrader.com/support/helpG...-us/export.htm
Leave a comment:
-
Hi Unsuitable,
Sorry for the confusion. The file contains the codes for the buttons and the grids + other unrelated variables which were used for other indicators. It is not a complete stand alone indicator and contains other variables (with declaration deleted) and thus would not compile. The main purpose is to show 1) the frame work, 2) the actual codes for the buttons and grids and 3) where they should be placed.
You have to copy and paste only the button and grid codes, including declarations, and placed in the same sections (eg. initialize inside State.SetDefaults, State.DataLoaded, etc) of your indicator.
Leave a comment:
-
Hi Unsuitable,
Attached is a file showing the grid and button codes that I used in my application, which are also functional with tabbed charts. Note that all of the codes are from samples provided by Ninjatrader.Attached Files
Leave a comment:
-
Yes that would be great!Originally posted by kkc2015 View PostHi Unsuitable,
Are you just looking for functional buttons on the edge of the chart screen? Please see attached chart screen.
If so, I could provide you with related codes, which are all from Ninjatrader samples.
[ATTACH]n1118752[/ATTACH]
Leave a comment:
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
51 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
31 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
165 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
100 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
160 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Leave a comment: