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

Can't access MainTabControl.Items parent from NTWindow

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

    Can't access MainTabControl.Items parent from NTWindow

    Hi.

    I'm trying access header tabs from a new window (NTWindow) created by indicator. I tried everything but i could find the correct way.

    Inside the indicator I access tabs bythis way:

    var chartWindow = Window.GetWindow(ChartControl.Parent) as Chart;
    var tabs = chartWindow.MainTabControl.Items;


    But inside addon it cant be accessed​.

    I tried also passing a parameter from indicator chart with actual chart but nothing works. Also with Owner methods.

    #2
    Hi franjcy,

    Please put the code below in the OnStateChange() function:

    Code:
    if (State == State.Historical) {
      if (isCharting) ChartControl.Dispatcher.InvokeAsync(() => {
          var chartWindow = Window.GetWindow(ChartControl.Parent) as Chart;
          var tabs = chartWindow.MainTabControl.Items;
       
          foreach ( TabItem tab in tabs ) {
              Print(tab.Header.ToString());
          }
      });
    }
    Regards,
    William
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      Originally posted by ninZa View Post
      Hi franjcy,

      Please put the code below in the OnStateChange() function:

      Code:
      if (State == State.Historical) {
      if (isCharting) ChartControl.Dispatcher.InvokeAsync(() => {
      var chartWindow = Window.GetWindow(ChartControl.Parent) as Chart;
      var tabs = chartWindow.MainTabControl.Items;
      
      foreach ( TabItem tab in tabs ) {
      Print(tab.Header.ToString());
      }
      });
      }
      Regards,
      William
      Class of type NTWindow doesn't have OnStateChange() function.

      Comment


        #4
        Hi franjcy,

        We have just created an indicator file. When pressing F5, it displays the NT window, and when pressing the button inside the NT window, it displays the header tabs.

        Please refer to the attached file below.

        Regards,
        William
        Attached Files
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #5
          Originally posted by ninZa View Post
          Hi franjcy,

          We have just created an indicator file. When pressing F5, it displays the NT window, and when pressing the button inside the NT window, it displays the header tabs.

          Please refer to the attached file below.

          Regards,
          William
          Thanks for your contribution but it doesn't do what I need.
          In your example, you're creating a new tabControl on the NTWindow and then reading the tabs.
          What I need is, from a init window with charts in tabs, open a popup window (NTwindow) with a button and read the previous tabs from indicator was hosted.

          Comment


            #6
            franjcy,

            You need to declare a global variable for the chart so that it can be accessed anywhere in your code. In this example, we used "chartWindow" (line 33). Then, you need to initialize it (see line 73).

            Once initialized, you can use it throughout your code.

            Please refer to the attached file below.
            Attached Files
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by YoungCinco24, Today, 09:43 PM
            0 responses
            8 views
            0 likes
            Last Post YoungCinco24  
            Started by Apm123, Today, 08:21 PM
            0 responses
            6 views
            0 likes
            Last Post Apm123
            by Apm123
             
            Started by tony_28217, 09-07-2024, 01:21 AM
            2 responses
            28 views
            0 likes
            Last Post tony_28217  
            Started by Rudmax, 07-02-2024, 05:40 AM
            64 responses
            1,117 views
            1 like
            Last Post backtester831  
            Started by DayTradingDEMON, Today, 08:23 AM
            2 responses
            27 views
            0 likes
            Last Post DayTradingDEMON  
            Working...
            X