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

Closeing AddOnFrameworkWindow()

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

    Closeing AddOnFrameworkWindow()

    Hi,

    I will appreciate help from anyone here.
    I am trying to Close the NTWindow with a button click where xaml file type is Page.
    Any suggestion on how can I close the window, will be helpful.
    Last edited by asmmbillah; 05-10-2020, 03:38 PM.

    #2
    Hello asmmbillah,

    Calling this.Close() within the NTWindow class should close the window.

    Below is a link to an example addon that uses NTWindow.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply. I am also trying to use a bool to show the NTWindow on chart with below code when the indicator is added to the chart:

      else if (State == State.Configure)
      {
      if (bool is true)
      NinjaTrader.Gui.NinjaScript.AddOnFrameworkWindow app = new NinjaTrader.Gui.NinjaScript.AddOnFrameworkWindow() ;
      app.Show();
      }
      but it it does not check the bool value to be true.
      Or should I use it to AddOnPage.xaml.cs or AddOnFrameworkWindow class ? I am using your sample file in help guide for visual studio. Please advise.

      Comment


        #4
        Hello asmmbillah,

        The 'is' command compares types.

        if (MyScriptClassName is Strategy)

        Your code is checking if the bool struct is true. It is not.

        You need to name your variable.

        Then use '==' to compare if it equal to true (and not the type of true).

        bool myBool = true;

        if (myBool == true)


        Also, below is a link that demonstrates how to open a window from code.
        https://ninjatrader.com/support/foru...686#post492686
        Last edited by NinjaTrader_ChelseaB; 05-12-2020, 02:07 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your reply. Actually when I said, if (bool is true) I meant
          first added this below code to AddOnPage first:

          namespace NinjaTraderAddOnProject
          {
          public partial class AddOnPage : Page
          {
          public static bool myBool = false;

          public AddOnPage()
          {
          if (//condition to be true)
          {
          myBool = true;
          }
          }
          }

          then adding the below code in indicator script:

          if (NinjaTraderAddOnProject.AddOnPage.myBool)
          {
          NinjaTrader.Gui.NinjaScript.AddOnFrameworkWindow app = new NinjaTrader.Gui.NinjaScript.AddOnFrameworkWindow() ;
          app.Show();
          }

          But it is not checking bool value correctly.
          Last edited by asmmbillah; 05-12-2020, 01:52 PM.

          Comment


            #6
            Hello asmmbillah,

            Have you created an instance of the Page extended object?

            Are you checking the bool from that instance?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              thanks for your reply. I am not sure what you tried to mean by that. can you please explain little bit for me?

              Comment


                #8
                Hello asmmbillah,

                This would not be a static class so a new instance would need to be instantiated with the 'new' keyword.

                Where is this class being created? Is it saved to a variable? Are you checking that created instance to see the state of the bool in that instance?


                As an example, I create a new NTTabPage on line 111 and add this to the tabControl in the example linked below.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks for your reply. Yes I am creating an instance like below for that page.

                  namespace NinjaTrader.Gui.NinjaScript
                  {
                  public class AddOnFrameworkWindow : NTWindow
                  {

                  public AddOnFrameworkWindow()
                  {
                  Caption = "text " ;
                  //height and width skipped to save space here

                  if (myBool) // this bool is checked in the page
                  {
                  Content = new AddOnPage();
                  }

                  }
                  }
                  }

                  But then it does not show the page content only wihtin the window, but it does show rest of the part of the window, like caption and border. I want the whole window not to show,if the bool is false.
                  Last edited by asmmbillah; 05-12-2020, 04:00 PM.

                  Comment


                    #10
                    Hello asmmbillah,

                    Is the bool declared within the AddOnPage()?

                    Are you attempting to check this before the new AddOnPage is created?

                    It won't exist until the AddOnPage instance is created..

                    Maybe create the AddOnPage instance and assign this to a variable. Then using that variable to access the saved instance check the bool as a child property.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by fx.practic, 10-15-2013, 12:53 AM
                    5 responses
                    5,406 views
                    0 likes
                    Last Post Bidder
                    by Bidder
                     
                    Started by Shai Samuel, 07-02-2022, 02:46 PM
                    4 responses
                    98 views
                    0 likes
                    Last Post Bidder
                    by Bidder
                     
                    Started by DJ888, Yesterday, 10:57 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by MacDad, 02-25-2024, 11:48 PM
                    7 responses
                    160 views
                    0 likes
                    Last Post loganjarosz123  
                    Started by Belfortbucks, Yesterday, 09:29 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post Belfortbucks  
                    Working...
                    X