Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Modifications to chart WPF elements and tab considerations

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    Comment


      Hello REI140205,

      Possibly you could set and look for AutomationID's with strings that have a incremented value.. You could use string.Substring to match the first part of the string, parse the number on the second part of the string, and this would tell you how many times that control has been added to the wpf on that tab. Each time the is added and there is already one existing, you might change the color for the new object.

      The ChartToolBarCustomMenuExample shows a little of finding and setting AutomationIds.
      Chelsea B.NinjaTrader Customer Service

      Comment


        Hello Community,

        Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum.
        Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm


        I am uploading an updated version of these scripts that is combined into one example script, with concepts separated by regions.

        There are some fixes with the right side panel grid-splitter, and with styling buttons and menus. There are also some important fixes for adding multiple instances to the same tab and to different tabs.

        (Old versions can be found on post #1 of this thread)

        Update 2020.12.29: changed detecting the current tab, still having errors with the custom DropMenu class setting the menu background color (Popup) when loading from xml

        Update 2020.12.31: The ViewBox template was being accessed too early. Moved DropMenu popup border changes to the ViewBox.Loaded event using a WeakEventManager. This fixes the issues with rapidly reloading and when loading from xml. Still having an issue with the TabItems in the TabControl moving.

        Update 2021.9.28: Moved CreateWPFControls() to State.Historical as State.DataLoaded is before the ChartControl is completely ready.

        Update 2021.10.5: When closing a tab, the ChartControl could be null. Changed the TabSelected() method to return if ChartControl is null.

        Update 2021.10.6: Last update on the forums.
        !!! There has been a change to the namespace and folder which will cause a duplicate class error. The old version must be removed before attempting to import this new version !!!
        (open NinjaScript Editor -> Indicators -> right-click SampleWPFModifications -> Remove)


        Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum.
        Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm
        Attached Files
        Last edited by NinjaTrader_ChelseaB; 08-01-2022, 11:58 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          Thank you Chelsea. This is the most thorough and useful sample indicator on custom buttons / menu.

          Comment


            Hello ChelseaB,

            It seemed relevant to ask the question in this thread. How does one remove the space for the icon for the NTBarMenu if it is not needed? Tried a few things, didn't work. Keep in mind the menuItemGroup is grabbing the mainMenuItemStyle, so we'd have to override the property that makes space for the icon.

            Code:
            NinjaTrader.Gui.Tools.NTMenuItem menuItemGroup = new NinjaTrader.Gui.Tools.NTMenuItem()
            {
              Style = mainMenuItemStyle,
              Header = "Buttons"
            };
            
            menuItemGroup.Margin = new Thickness(0);
            menuItemGroup.Padding = new Thickness(0);
            menuItemGroup.IconRightMarginMultiplier = 0;
            Talking about this specfic space for the icon, https://i.imgur.com/TyuVvD7.png

            Thanks
            Unsuitable
            NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

            Comment


              Hello Unsuitable,

              I do not know how to remove that space.

              I recommend that you try asking on a website for programming C# questions and WPF questions like StackOverflow.
              Chelsea B.NinjaTrader Customer Service

              Comment


                Did some digging and there may be a way of making a style and stuff. Or one can cheese a solution by setting a negative margin to the menuItem in question. -30 seems to be the right amount of pixels to remove. :P

                Code:
                Margin = new Thickness(-30, 0, 0, 0)
                Unsuitable
                NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                Comment


                  Although the solution works. the menu is shifted to the left where the icon would be. I asked a question on stack overflow and it got closed. Stackoverflow is a bunch of d!ck5, NinjaTrader development is a better and friendlier forum for questions. GEEZ
                  Unsuitable
                  NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                  Comment


                    For anyone who's looking to make a custom icon using System.Windows.Media.Geometry icon = Geometry.Parse() for the NTMenuBar, that can be achieved by making a SVG file (Inksape or illustrator). By opening up the SVG file in a text editor such as NotePad++, one can grab the path data. Then use Geometry.Parse() to make the icon.

                    Hope this helps!
                    Unsuitable
                    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                    Comment


                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello Community,

                      I am uploading an updated version of these scripts that is combined into one example script, with concepts separated by regions.

                      There are some fixes with the right side panel grid-splitter, and with styling buttons and menus. There are also some important fixes for adding multiple instances to the same tab and to different tabs.

                      Old versions can be found on post #1 of this thread)
                      Hi Chelsea,

                      Are you able to add a simple logic like (buy when 3 HH and 3HL) on how to place buy/sell orders using the selected ATM strategy from the chart trader when the newly added button is clicked. This would really help to make the example code usable in the real context (for newbie like myself) instead of just showing text printed on the chart when the buttons are clicked.

                      Looking forward to the updated example script.

                      Comment


                        Hello amul_shail2020,

                        Thank you for your post.

                        Please clarify the condition 'buy when 3 HH and 3HL'. Are you wanting to press a button and then wait for the HH condition to become true?

                        The SampleWPFModifications script is made simple so that you could use it as a starting point for anything you would like to add. For example, you can combine samples, but working with this level of development will require knowing C# well so you can learn from existing content.

                        See this forum post that contains a sample script that shows how to get the ATM selector and start a strategy - https://ninjatrader.com/support/foru...egy#post752775

                        Please note that managing an ATM in a NinjaScript might get pretty involved. You may want to start by looking at the SampleAddon script in the link below that has a full ATM example using the ATM selector WPF Control

                        SampleAddon - https://ninjatrader.com/support/help...t_overview.htm

                        Let us know if you have further questions.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          That is correct. Go long when 3 bar HH and 3HL condition is met...note this is an example logic. I am more looking forward to getting a working example to submit order when the Button is clicked or when condition is met. The order type can be Buy/Sell Market order using a Profit target /Stop loss prices or pull the Profit Target / Stop loss directly from the ATM template selected from the Chart trader or Super Dom when the button is clicked. Hope this helps.

                          Comment


                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello Mindset,

                            Use prints to now when the method is being called, use TraceOrders to know when an order is being ignored or cancelled.

                            Below is a link to a forum post that demonstrates using prints and TraceOrders to understand behavior.


                            Enable TraceOrders, then print the time of the bar and all values used in the conditions that place orders.
                            Save the output to a text file.
                            Include this with your next post.

                            I am happy to assist with analyzing the output.
                            Hi Chelsea

                            I tried adding TraceOrders as per the help file - I get that it does not exist in the current context?
                            Is it only available in strategies?

                            Comment


                              Hello Mindset,

                              TraceOrders is specific to Strategies and is not available to Indicators or Addons.


                              Through the addon approach orders would be submitted though Account.Submit().


                              It would be possible to assign an event handler method to the Account.OrderUpdate event and use NinjaTrader.Code.Output.Process() to print the order information to the output window.

                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                Hello Chelsea,

                                thanks for the exellent work.
                                I have a problem with the indicator when I use it in window with more then one Tab.
                                If I restart NT8 there are two menus in the Top Menu from both Tabs.
                                After clicking the tab everything work fine.
                                (see attached screen print)

                                Can that be eliminated?

                                Thanks for your help in advance


                                Click image for larger version

Name:	NT8_Sample WPF Modifications_2020-12-08_150645.jpg
Views:	1819
Size:	136.9 KB
ID:	1131261

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by ghoul, Today, 06:02 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post ghoul
                                by ghoul
                                 
                                Started by Barry Milan, Yesterday, 10:35 PM
                                6 responses
                                18 views
                                0 likes
                                Last Post Barry Milan  
                                Started by DanielSanMartin, Yesterday, 02:37 PM
                                2 responses
                                13 views
                                0 likes
                                Last Post DanielSanMartin  
                                Started by DJ888, 04-16-2024, 06:09 PM
                                4 responses
                                13 views
                                0 likes
                                Last Post DJ888
                                by DJ888
                                 
                                Started by terofs, Today, 04:18 PM
                                0 responses
                                12 views
                                0 likes
                                Last Post terofs
                                by terofs
                                 
                                Working...
                                X