Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 traderqz, Yesterday, 09:06 AM
    3 responses
    21 views
    0 likes
    Last Post NinjaTrader_ThomasC  
    Started by f.saeidi, Today, 10:19 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by kujista, Today, 06:23 AM
    5 responses
    15 views
    0 likes
    Last Post kujista
    by kujista
     
    Started by traderqz, Today, 12:06 AM
    3 responses
    6 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by RideMe, 04-07-2024, 04:54 PM
    5 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X