Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

tabs and UserControlCollection

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

    tabs and UserControlCollection

    When using the UserControlCollection to add control items is it required for me to handle removing the controls if the tab is changed to a different chart?

    I don't see any examples that use chartWindow.MainTabControl.SelectionChanged events to remove items from the UserControlCollection.

    I read the user guide and I know I have to remove control items on OnState == State.Terminated but if my indicator remains on the chart but the tab is changed I don't see any procedures written in the user guide or in any examples.

    Also, one other question is that I want to add multiple indicators all using the UserControlCollection and so one indicator would be left aligned while another different indicator would be right aligned. I've written the code and it seems to be working but I want to make sure that I'm doing something that is allowed and won't turn into broken software later.

    regards

    #2
    Hello dtl-saw,

    No, this is not required. The UserControlCollection is unique to each ChartControl. (Try adding an indicator with an object added to the collection to one tab and not another and try switching tabs to observe the behavior).

    (edit)
    The UserControlCollection is a collection of FrameworkElements (window controls) that NT adds to the chart. Its somewhat like a page but does not have many properties of itself. Adding an a grid helps to organize the space with a famework object that has a lot of properties. Each indicator added to that tab would affect that tab. The items would either layer on top of each other or be aligned as written in the script.

    (under review)
    If they are added to the same grid, to different columns and rows they would position next to each other.
    Last edited by NinjaTrader_ChelseaB; 05-24-2021, 10:59 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea B.
      As I read your response then I think that the following example would be possible:
      I use 1 indicator on a tab page (chart) to create a grid and then add that grid into the UserControlCollection and then that grid would be available for other unrelated indicators placed onto the same tab page (chart) to then place additional control elements onto the grid defined by the first indicator.
      Is that possible?
      Since the grid goes into the UserControlCollection named then that grid is available for other indicators if they are written to use it? Is that possible or is it not possible for an indicator to use a grid created by a different indicator?
      Also, seems like the indicators have to be ordered correctly in the UI to make sure the grid is defined and in the UserControlCollection before the other indicators are initialized but you do allow for that already in the UI.

      Comment


        #4
        Hello dtl-saw,

        You could create the grid if it doesn't exist in any script.

        If these are items that are all going to be in the same chart tab, it would make sense to put these in one indicator.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          thanks again Chelsea B.

          yes it would make sense to put them all in 1 indi and i've tried but the complexity goes up exponentially the more separate indis i add into one big one and then i have some that update on bar close and others on price change and others on different panels plus i hate 50,000 lines of code in 1 file for my swiss army knife indi --
          it becomes a much simpler problem if i can code the indis separately and then give each one it's own little dedicated control menu full of submenus. it's also much easier to maintain and debug the code when it's just 1 indi per function or purpose.

          Comment


            #6
            i have 2 different indis on the chart and one is creating a grid and adding that grid to the UserControlCollection while the other indi is querying the UserControlCollection for an object count.
            so if i use one indi and create the grid and add the grid to the UserControlCollection and then from the other indi query a UserControlCollection.count then i should get a count greater than 0.
            but in fact the count i get is zero. I know i can get a count greater than zero because i get a count of 1 after i add the grid from the indi that creates the grid.

            So, you can't see the items in the UserControlCollection that were made from another indi, but only the items made from the same indi

            this is not what i was expecting given your comments from before - maybe you can be more specific and if so could you give me an example of code showing how to get a reference to a grid that was placed in the UserControlCollection from another indicator?

            Comment


              #7
              Hello dtl-saw,

              In creating a test script, I am also experiencing this behavior and have created a ticket to have our development further investigate.

              I appreciate your patience and will be reporting back any findings from our development.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Any findings on this from your development team yet ChelseaB? It's been a week now.
                regards

                Comment


                  #9
                  Hello dtl-saw,

                  Our development has let us know this is expected behavior.
                  The UserControlCollection will only contain items added by that instance of a script.

                  I have submitted a feature request for the NinjaTrader development to consider allowing the items added to the UserControlCollection to be available to other script instances.

                  In the meantime it was suggested to have one indicator add items to the UserControlCollection and all other scripts either write to a file or use a static collection that the indicator will read from and add items from.


                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello dtl-saw,

                    I've received tracking ID# SFT-5269 for this request.


                    Please note, we receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing, so we cannot offer an ETA or promise of fulfillment.

                    When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number may be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

                    Release Notes -https://ninjatrader.com/support/help...ease_notes.htm

                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    579 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    334 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    551 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X