• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Audio Alert problem

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

    Audio Alert problem

    Audio alert problem
    I have a set of conditions that trigger a triangle at a swing low and draws a line from the that last swing low back to the previous swing low. I am also trying, without success, to trigger a sound alert to sound one time at this point, not for the duration of my set of conditions. I need to add to the conditions for the sound alert that the my user controlled variable “soundOn” to be true.
    At present the coding works but audio alert just keeps repeating as long as my original conditions exits, which could be for many minutes.
    Any ideas how to trigger the sound alert for one time only? By the way conditions for the alert my happen again later it the day.

    Thanks in advance.

    #2
    Hello Pete77,

    Thanks for your post.

    You could use a bool condition to make sure the sound is issued once, but then you will also need to define in your code a condition that would reset the bool so that the sound may be issued the next time it is needed. In the example below doitOnce is a bool.

    if (your sound conditions && !doitOnce)
    {
    // your sound code stuff here
    doitOnce = true; // set bool for one time use
    }

    later on:
    if (this is your reset condition)
    {
    doitOnce = false; // reset bool for new condition
    }
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Many thanks, will give that a try!

      Comment


        #4
        The NinjaScript Alert comes with a rearm time parameter. If you set that rearm time to 5 minutes, the specified alert will not be triggered a second time within 5 minutes, when it has fired once. Here is the syntax:


        Code:
        Alert(string id, Priority priority,  string  message, string soundLocation,  int  rearmSeconds, Color backColor,  Color  foreColor

        Comment


          #5
          Thanks Harry.

          I can't get any sound from Alert today for some reason. I will go back to PlaySound and see if I can get Paul's doitOnce to work.

          Comment


            #6
            I have tried mightily to limit my audio alert to one time only using rearm or doitOnce without success. I’m thinking of another approach which would be switching to “calculate at bar close” to reduce the repeats and try to limit the conditions for the alert to a point where the alert is no longer valid.
            To do this I need to designate some swing points that I can refer to for this purpose and my question now is what would be the best way to designate these swing points?
            My code has already created variables and assigned values for swingLowIndex and swingLowValue. Is there some way to use these as parameters to name a point I could refer to?
            Thanks

            Comment


              #7
              Hello Pete77,

              Would it be possible for you to share a section of your code that contains the logic section where you are issuing the alert and then resetting it? If you would prefer, please feel free to send to PlatformSupport[at]NinjaTrader[dot]Com Atten: Paul and a reference to this thread.

              Thank-you.
              Paul H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Johnny, Today, 11:42 AM
              0 responses
              8 views
              0 likes
              Last Post Johnny
              by Johnny
               
              Started by habibalex, Today, 09:03 AM
              2 responses
              11 views
              0 likes
              Last Post sledge
              by sledge
               
              Started by ptpatrader, Today, 11:38 AM
              2 responses
              15 views
              0 likes
              Last Post ptpatrader  
              Started by emuns, Today, 11:20 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by chartish, Today, 10:33 AM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Working...
              X