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 use NTMessageBox in a class

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

    How to use NTMessageBox in a class

    Hi,

    I want to use the NTMessageBoxSimple from outside OnRender and OnBarUpdate. I want to use it from a different custom class but I get problems with ChartControl.Dispatcher and ChartControl.OwnerChart.

    How can I use the NT Message Box from an outside class ?

    ChartControl.Dispatcher.InvokeAsync(new Action(() => { NinjaTrader.Gui.Tools.NTMessageBoxSimple.Show(Window.GetWindow(ChartControl.OwnerChart as DependencyObject), " You cannot Split a Split Volume Profile !", "Alert", MessageBoxButton.OK, MessageBoxImage.Hand);
    }));

    #2
    Hello blar58,

    Thank you for your post.

    When calling your class pass the ChartControl as an overload to the function. For example:
    Code:
    MyMethod(ChartControl cc)
    Then you would call cc.Dispatcher.

    Please let me know if you have any questions.
    Last edited by NinjaTrader_PatrickH; 05-29-2017, 12:22 PM.

    Comment


      #3
      You are right

      Thanks

      Comment


        #4
        Hi, is there a way to change the text in the NTMessageBox if it has already been opened? For example, I would like to make a messagebox that closes automatically after 10 seconds and the seconds should be counted down in the messagebox. How can I access the text of the messagebox to change the seconds?

        Click image for larger version

Name:	Screenshot_3.jpg
Views:	297
Size:	14.4 KB
ID:	1192227
        sidlercom80
        NinjaTrader Ecosystem Vendor - Sidi Trading

        Comment


          #5
          Hello sidlercom80,

          There would not be a way to do that with the default messagebox, you would need to create your own WPF window for that type of use case. A window could be opened and you could save a variable to that window to update it later or call methods on your custom class. You can research Opening a new WPF window and also the Dialog concept for WPF windows in external resources.

          You can find an example of opening a window in the following link, you would only need the window class and how the window is opened using the random dispatcher. https://ninjatrader.com/support/foru...830#post759830

          Code:
          Globals.RandomDispatcher.InvokeAsync(new Action(() => new AddonShellNoTabsWindow().Show()));
          This would be used when you trigger the alert or whatever invokes the messagebox. You would need to save the above window to a variable if you plan to use it in some way later to update the window:

          Code:
          private AddonShellNoTabsWindow myWindow;
          
          later when you open the window
          [B]myWindow = [/B]new AddonShellNoTabsWindow();
          Globals.RandomDispatcher.InvokeAsync(new Action(() =>[B] myWindow[/B].Show()));
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hi,
            I've added the code in the first post to my indicator but after refreshing the chart alert pop up appears like 50 times in a row. The code is inside an if statement fired when my conditions to plot signals are met.

            Comment


              #7
              Hello cgvmlg,

              When you refresh the chart the indicator will process historical bars so if your condition is true it will generate popups for each instance. You may want to surround that with a condition checking if the state is realtime: if(State == State.Realtime)
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by llanqui, Today, 03:53 AM
              0 responses
              5 views
              0 likes
              Last Post llanqui
              by llanqui
               
              Started by burtoninlondon, Today, 12:38 AM
              0 responses
              10 views
              0 likes
              Last Post burtoninlondon  
              Started by AaronKoRn, Yesterday, 09:49 PM
              0 responses
              15 views
              0 likes
              Last Post AaronKoRn  
              Started by carnitron, Yesterday, 08:42 PM
              0 responses
              11 views
              0 likes
              Last Post carnitron  
              Started by strategist007, Yesterday, 07:51 PM
              0 responses
              14 views
              0 likes
              Last Post strategist007  
              Working...
              X