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

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 rexsole, Today, 08:39 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          6 responses
          28 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by gbourque, Today, 06:39 AM
          2 responses
          14 views
          0 likes
          Last Post gbourque  
          Started by trilliantrader, Yesterday, 03:01 PM
          3 responses
          31 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by Brevo, Today, 01:45 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X