• 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 Erwin Beckers, 11-04-2018, 02:39 AM
              4 responses
              69 views
              2 likes
              Last Post brucerobinson  
              Started by ntbone, Today, 01:25 AM
              0 responses
              5 views
              0 likes
              Last Post ntbone
              by ntbone
               
              Started by bomanpbm, Yesterday, 09:27 PM
              0 responses
              5 views
              0 likes
              Last Post bomanpbm  
              Started by tgn55, Yesterday, 08:47 AM
              0 responses
              11 views
              0 likes
              Last Post tgn55
              by tgn55
               
              Started by ballboy11, 05-04-2019, 10:26 AM
              6 responses
              61 views
              0 likes
              Last Post Kermit
              by Kermit
               
              Working...
              X