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

MessageBox on associated chart NT7

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

    MessageBox on associated chart NT7

    Hi,
    I incorrectly posted this message in the NT8 Indicator development and I don´t know the reason why it appears now as moved:




    The support team provided me a potential answer which does not work and I´d like to know whether it´s still being studied by someone.


    I reintroduce here the content of my original request for help:
    "Hi,
    I use a commercial product called Total Alert which displays a window box on the chart where an alert is triggered.
    I want to reproduce said behavior when a specific condition occurs. By using the following method:
    MessageBox.Show(DateTime.Now.ToString() + "EMA cross" + Time[0] + "," + Close[0] + "," + Instrument.FullName , "Alert" , MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    I get the popup window. However, said window shows up on the chart which is currently active (owner of the message box is by default the currently active window).

    In the Internet, I´ve seen that the "parent windows" should be somehow referenced within said MessageBox instruction but I don´t know how.

    source : https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
    "

    The solution proposed:
    "You could try referencing the ChartControls parent control and casting it to the IWin32Window" has not worked since the message still shows up in the current active window and not in the "real" parent window.

    #2
    Hello,

    Thank you for the post.

    In the other thread, it was noted that the solution provided would not center the box. Centering is not a default option for the message box, you can, however, search online for alternative ways to do that. As noted in the other this is not something I could further assist with as this would be outside of the scope of NinjaScript support.

    To expand on the prior post further, you can utilize the ChartControl.Parent for modal focus with the message box. The MSDN article you linked describes how the parent is used for modal focus but the active application window is used for placement, so at this point, your outcome is matching the MSDN description and my description from the other thread.

    Some possible options to further center the window might include the following:

    Is there a easy way to center MessageBox in parent form in .net 2.0


    As these are general C# concepts which are not documented or supported NinjaScript concepts, I would be unable to provide a specific example here, but you can search for C# solutions to this question and test them in NinjaScript.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi,
      I did not ask for message centering but about how to show the messagebox in parallel with its parent window. The solution proposed doesn´t work, it does the same thing as my original code, it shows the message box on the current active window, which could be or not, its "real"parent window. I want to force said message to show up always with its "real" parent window.

      Comment


        #4
        Hello,

        Thank you for the post.

        Correct, as noted the box will show up over the active window but will be in front of the parent window (zorder) which may or may not be in that windows rectangle. To force the message box to appear in a different location (center or any other location) you would need to look into other C# solutions outside of NinjaTrader/NinjaScript, a few were linked in the prior post. This is not something our support can directly assist with though.

        The message box has no native support for positioning other than what you see it doing, this is a windows forms C# feature and is not something NinjaScript controls. NT7 uses Windows forms, so you can use any windows forms solutions to generate a window in a position of your choosing. Going forward in NT8 there are native windows that you can make into modals or not if you want to make custom alerts or whole tools.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          By parent window I meant the chart where the indicator with the messagebox code is running.
          For example, if I´ve three charts: YM, NQ, ES running the same indicator with the MessageBox.Show code, if an EMA cross condition happens on the NQ chart while monitoring the ES chart, I want the message to appear automatically with its NQ chart without having to select manually the NQ chart so that I can take a faster decision as to whether to take that trade or not. Currently, in the situation described, the message shows up on the current active chart, the ES chart.
          As commented in my original message, the Total Alert indicator does exactly what I´m describing to show a triggered alert level.
          Last edited by motog4; 07-24-2018, 12:59 PM.

          Comment


            #6
            Hello,

            Thank you for the post.

            Yes, It is clear on the description of what you are wanting to do, I think the key take away from my prior reply would be the following:

            The message box has no native support for positioning other than what you see it doing, this is a windows forms C# feature and is not something NinjaScript controls
            Being that it has no support for position placement, you would need to do some research into other ways to accomplish the positioning. I understand the other item does this already, they have programmed it to do so. Have you tried asking the support for that item to see if they can provide any insight on how they are accomplishing that currently?

            You could also research "creating modal windows in windows forms C#" online for some other ideas on how to make child windows that are specific to a parent and can be placed at a specific location.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi,
              I´m gonna try it in a roundabout way, is it possible to focus a chart from an indicator and then set a very short timer to show the messagebox?

              Comment


                #8
                Hello,

                You could look into C# ways of focusing windows if wanted to try it out, there is no specific NinjaScript syntax to focus the NinjaTrader windows. Any guides you find online surrounding focusing windows in Windows Forms in C# should apply.

                UI development is a subject our support unable to assist with for NT7 as UI development is not officially supported for NT7. I could suggest using NT8 as there are many guides and samples surrounding UI development for various tasks.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi,
                  even if my programming skills are very limited, if I create a new Windows Form code, where should I place the .cs code in the NT7 folders?

                  Comment


                    #10
                    Hello,

                    You would need to use a valid NinjaScript type for the code to be relevant. For example, placing .cs file you create with some UI elements into the Documents\NinjaTrader 7\bin\Custom folder would have no effect unless NinjaTrader knows what to do with it. You would need to create an indicator or strategy that then uses the code you made in some way.

                    Please let me know if I may be of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      I solved this issue long time ago and since I´ve reported another issue today, here I share my solution:

                      ChartControl.Parent.FindForm().BringToFront();

                      I still don´t know how the support was not able to provide me the above solution!

                      Comment


                        #12
                        Hello motog4,

                        Thanks for sharing your solution.

                        Please note that the code is used is not documented or supported. You are welcome to use undocumented/unsupported code for your needs but we would not be able to assist with using that code.

                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by cre8able, Yesterday, 04:22 PM
                        1 response
                        13 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by stafe, 04-15-2024, 08:34 PM
                        5 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by StrongLikeBull, Yesterday, 04:05 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by Mestor, 03-10-2023, 01:50 AM
                        14 responses
                        375 views
                        0 likes
                        Last Post z.franck  
                        Started by molecool, 10-09-2017, 10:48 AM
                        5 responses
                        1,621 views
                        0 likes
                        Last Post trader-ap  
                        Working...
                        X