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

How to open a dialog from a script

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

    How to open a dialog from a script

    What is the way to open a WPF (modal) dialog from a script (Indicator, or BarsType)?

    I tried creating a WPF Window xaml, with its default partial handler class in Visual Studio, but I couldn't figure it out how can I run the InitializeComponent in the class: it says it cannot be found thus the xaml couldn't be applied.

    How can I make a simple popup dialog then?

    #2
    Hello Zapzap,

    Thanks for your inquiry.

    My colleague Chelsea has shared a sample Indicator and AddOn bundle where the Indicator can create an interactive AddOn window upon a button press and the AddOn window can then modify that indicator so it can display certain values. It may be a good example to help accomplish what you are trying to do.

    Our AddOn Framework example from the help guide can be used for further reference in creating NTWindows, but the sample should be enough to demonstrate creating an interactive window from an indicator that uses XAML for the window.

    Chelsea's example - https://ninjatrader.com/support/foru...86&postcount=8

    The AddOn Framework example is publicly available on this page of the help guide: https://ninjatrader.com/support/help...t_overview.htm

    Please let us know if we can be of further help.
    JimNinjaTrader Customer Service

    Comment


      #3
      PHP Code:
      FileStream fs = new FileStream(System.IO.Path.Combine(NinjaTrader.Core.Globals.UserDataDir, @"bin\Custom\AddOns\SetIndicatorValueFromAddonWindowExampleToolsContent.xaml"), FileMode.Open); 
      Do we really need filestream for this? What's up with exporting stuff to DLLs?

      Comment


        #4
        Hello Zapzap,

        You don't have to use a FileStream per se, but you will have to access the file and load it into memory so it can be used by the AddOn. The AddOn Framework example uses System.IO.Stream.

        I'm not sure what you are referring to with DLL's though. We have some information on exporting DLL's openly available in our help guide that details how to export NinjaScripts as DLL's. I'll provide a link below. If it doesn't answer your question, could you go into further detail?

        Exporting DLL's - https://ninjatrader.com/support/help...riptAsAssembly
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello Zapzap,
          I'm not sure what you are referring to with DLL's though.
          That you are showing people to reference a xaml file which won't exist if you compile your whole thing into a DLL.

          BTW the NTWindow height is not changeable.

          Comment


            #6
            Hello Zapzap,

            You can either include the XAML by compiling the DLL in Visual Studio or by adding the XAML file to the zip package after exporting from NinjaTrader.

            This is outlined under the Considerations for Compiled Assemblies doc. Please see the "Adding XAML and Other Files Into a DLL" section therein.

            Considerations for Compiled Assemblies - https://ninjatrader.com/support/help...assemblies.htm

            NTWindow width and height will use the hard coded values initially and then save them to Documents/NinjaTrader 8/UI.xml. Once saved to Documents/NinjaTrader 8/UI.xml, NinjaTrader will use the stored values from the xml.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DanielTynera, Today, 01:14 AM
            0 responses
            2 views
            0 likes
            Last Post DanielTynera  
            Started by yertle, 04-18-2024, 08:38 AM
            9 responses
            40 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by techgetgame, Yesterday, 11:42 PM
            0 responses
            9 views
            0 likes
            Last Post techgetgame  
            Started by sephichapdson, Yesterday, 11:36 PM
            0 responses
            2 views
            0 likes
            Last Post sephichapdson  
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,615 views
            0 likes
            Last Post aligator  
            Working...
            X