Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MessageBox shows infinitely

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

    MessageBox shows infinitely

    Hi,

    I developed an indicator and I wish it could play a sound and show a pop up message on certain condition.
    The sound works but the message shows up in infinite loop.

    Here's my code:

    Code:
    if (CurrentBar != savedBar) // if current bar is NOT equal to the savedBar
                    {
                        PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Alert4.wav");
                        MessageBox.Show("This is an OnBarUpdate() test", "Testing OnBarUpdate()!");
                        savedBar = CurrentBar; // save the current bar here to make them equal
                    }​
    I'd like the pop up to overlay everything I have opened if it is possible.

    Thanks,

    #2
    Hello Vincere,

    Thank you for your post.

    It appears you are using the Microsoft MessageBox object. There is also a NinjaTrader message box called NTMessageBoxSimple that you could test out to see if it achieves your desired result:


    As for the infinite loop, I suggest adding a Print statement to check the values of CurrentBar and savedBar to verify if the condition might be triggering multiple times. Here is an example of a print statement you could add both outside of your condition as well as inside of your condition:

    Print(String.Format("{0} CurrentBar: {1} savedBar: {2}", Time[0], CurrentBar, savedBar));

    For more information about using prints as a debugging tool:


    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    91 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    48 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X