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

Instantiating external window

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

    Instantiating external window

    Hi,
    I'm trying to create a form as an initial prototype for a much larger project.

    I've built a dll with a form in Visual Studio targeted to Dot Net 4.5. I declare my using clause at the top:

    using NinjatraderTest;

    I then declare my form in my indicator class as follows:

    NinjatraderForm frm;

    I initially tried to instantiate the form in my State == State.SetDefaults:as follows

    frm = new NinjatraderForm();
    frm.Show();

    and destroying it in the State.Terminated:

    else if(State == State.Terminated)
    {
    frm.Close();
    }

    but I was getting multiple forms created whenever the Indicators form was was brought up. I realized my mistake and then moved the creation to State == State.Historical.

    But this seems to work but the dialog seems hung. I then thought this may be due to the multithreading and tried to use the Dispatcher and moving the creation and termination to the functions called by the Dispatcher. However this does not seem to work as the form doesnt 'appear'.

    Is there a concrete example on how to do this please?
    Thank-you,
    iq



    #2
    Hello iq200,

    Thank you for the post.

    If you are opening a totally new window it would likely be suggested to do it in the same way that our addon sample does, could you try doing the following and see if that works in your use case?



    Code:
    Core.Globals.RandomDispatcher.BeginInvoke(new Action(() => new NinjatraderForm().Show()));

    If that does not work I would say the next best way to figure out what is happening would be to look at the structure of what you created and compare that to the general NTWindow class shown in the above linked "addon basic" sample. That is able to open a new window so if you are doing it in a different way that may be part of the problem. Additionally you mentioned "Form", if you are referring to a non wpf window that could also relate to the problem.

    I look forward to being of further assistance.


    JesseNinjaTrader Customer Service

    Comment


      #3
      Many thanks for your reply Jesse. I'll have a look.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by doihaveto13, Today, 12:46 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by owen5819, 05-11-2024, 02:24 PM
      3 responses
      20 views
      0 likes
      Last Post owen5819  
      Started by Vitamite, Today, 12:48 PM
      0 responses
      5 views
      0 likes
      Last Post Vitamite  
      Started by MrAdamSK, 04-02-2024, 11:25 PM
      3 responses
      41 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by lakman184, 03-24-2024, 01:30 PM
      7 responses
      36 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X