Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Play Sound once?

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

    Play Sound once?

    Hey all,

    I'd like an audio warning when the the bid price rises above a down trending ema. My code works fine but I only want the audio file to play once and then wait for price to go below the ema to reset.

    How do I change the play sound file to do what I want?

    Code:
    // Condition set 1 looks for a short down trend in the EMA three bars back
                condition1 = (EMA(14)[3] > EMA(14)[2] && EMA(14)[2] > EMA(14)[1] && EMA(14)[1] > EMA(14)[0]? true : false);
               
                //condition set 2 looks for the bid price to break above the ema for a short signal pull back warning
    
                condition2= (GetCurrentBid() > EMA(14)[0]? true : false);
                
                 /* Condition set 3 takes all conditions and if they all equal true statements it plays a warning sound*/
    
                if (condition1 && condition2)
                {
                   
                    PlaySound(audiofile);
                }
    Thanks for all the help.

    #2
    skikg, you will need to create a variable that gets set to true for when your conditions are met and then as soon as the sound file plays, reset the variable to false. Then you can have it be set true again as soon as the conditions are right.

    Basically, you just need a variable that gets set/reset at the appropriate times.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Got it Austin, Thanks for the help.

      Comment


        #4
        How do I reset variable after it triggers first time?

        I have set the variable but once it triggers once how do I reset it? I want the script to run and the variable to reset after each 5 min bar. Can I do this in wizard? thanks

        Comment


          #5
          ninjablanks, I believe it is possible within the Wizard, but you'll have to get creative with the variables. You can use the user defined variable named Variable0 and then just set it to 1 when your condition is true. Then when Variable0 is set to 1, do whatever action you want it to and reset it back to 0.
          AustinNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          634 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 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
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X