Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sound Alerts Triggered at same Time

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

    Sound Alerts Triggered at same Time

    Hi Guys. I have had an annoying problem with sound alerts for quite some time and would be grateful for some help. Basically I trade multiple instruments and sound alerts are critical. Here is a snippet of the code:

    PHP Code:
    if (FirstTickOfBar) boolAlertSounded = false;    
    
    if (!boolAlertSounded)
                            
                        if (Instrument.MasterInstrument.Name == "6E"){PlaySound("6elongdivergence.wav");}
                        else if (Instrument.MasterInstrument.Name == "CL"){PlaySound("cllongdivergence.wav");}
                        else if (Instrument.MasterInstrument.Name == 
                        boolAlertSounded = true; 
    
    The problem with this is if 3 instruments trigger at once on the first tick of the bar I only hear one alert because only one can be heard at a time. The only way around this I see is adding some sort of timer eg:

    if (Instrument.MasterInstrument.Name == "6E")

    SET TIMER TO WAIT 5 SECONDS

    {PlaySound("6elongdivergence.wav");}

    else if (Instrument.MasterInstrument.Name == "CL")

    SET TIMER TO WAIT 10 SECONDS

    {PlaySound("cllongdivergence.wav");}


    boolAlertSounded = true;

    Any ideas how to achieve this?

    Thanks in advance
    DJ

    #2
    djkiwi,

    Why not use the Alert() method? It has a cooldown timer, and also outputs more information to the Alert Window. It can play a sound as well.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Sound Alert

      Hi Adam, I thought you might say that . Actually I used to use that before but the problem was it would go off every 60 seconds or so. Say a 10 Renko bar may sit there for 30 minutes. If I set it for 30 minutes then there were 5 bars in 30 minutes how would that work?

      Basically l like the firsttickofbar concept but I'm not sure how the Alert could be used with that because it would still trigger at the first tick of bar irrespective of the Alert timer set? Am I understanding this correctly?

      Thanks
      DJ

      Comment


        #4
        djkiwi,

        If you used the first tick of bar criteria it would only call the alert once at the first tick of each bar as long as the other conditions were true, however may call it for more than one instrument.

        The alert would be easiest to remedy your sound issue, as it would allow some cooldown if you gave it the same alert name between instruments. It would also let you see if for example 3 instruments had the alert when you only heard the sound once. You could also print to the output window, or log to help you decipher how many instruments generated an alert at the same time.



        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X