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

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 bmartz, 03-12-2024, 06:12 AM
              5 responses
              32 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              13 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by cls71, Today, 04:45 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X