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