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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    627 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    567 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X