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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    160 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    307 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    348 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    178 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X