Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use of a soundfile in an indicator

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

    Use of a soundfile in an indicator

    Hi.

    Am working now with a sound file. The sound file is 4 seconds in length. It kicks in when the conditions are met. However, as I am using it on a 5Min DataSeries whenever it kicks in, it stays in and the sound file is played over and over for 5 minutes or longer as the conditions still exist. What I would like is for it to play perhaps 3 or 4 times but then stop.
    And only kick in again when the conditions are being met again perhaps 20 minutes or half an hour later. In which way code-wise could I achieve it doing that?

    // Condition set 1
    if (Close[0] > Opens[0][0]
    && Close[0] > EMA(BarsArray[0],13)[0]
    etc.etc. )
    {
    BarColor = upColor; PlaySound(@"C:\Sounds\mysound.wav");
    }
    else if (Close[0] > Opens[0][0])
    {
    BarColor = Color.Empty;
    }

    sandman

    #2
    Hello Sandman,

    You condition is going to be the only thing that determines when and how often your sounds is going to play. You may want to use the Alert() method that will also play a sound and has an option for "Rearm in Secons" (rearmSeconds) that you may use to be able to help manage how often your sound is going to play. For example if you set the "reamSeconds" to 1800 and your condition is hit, the sound will not play even if the condition is hit until 30 minutes have passed. Once 30 minutes have pasted, if the condition is hit again the sound will play again.

    Here is a link to our Help Guide that goes over the Alert() method that you may use.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    309 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    349 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X