Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript Alert sound not playing on trigger

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

    NinjaScript Alert sound not playing on trigger

    Hi team,

    I have completed porting one of my custom indicators to NT8, which triggers an Alert when the price crosses either side of an envelope around an SMA.

    The indicator works fine, and the Alert is displayed correctly in the Alerts window, however the sound does not play. Here is the relevant line of code:

    Code:
    Alert("xAbove", Priority.High, "Cross above Envelope!", "Alert4.wav", 30, Brushes.Black, Brushes.Red);

    #2
    Originally posted by ours_solaire View Post
    Hi team,

    I have completed porting one of my custom indicators to NT8, which triggers an Alert when the price crosses either side of an envelope around an SMA.

    The indicator works fine, and the Alert is displayed correctly in the Alerts window, however the sound does not play. Here is the relevant line of code:

    Code:
    Alert("xAbove", Priority.High, "Cross above Envelope!", "Alert4.wav", 30, Brushes.Black, Brushes.Red);


    .
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      OK, I have added the Sounds path to the Alert() method, and it seems to be working.

      However, I am experiencing some odd behaviour of the NinjaScript -triggered alerts.

      I have a Chart window with 2 tabs running the same indicator that generates the alerts, one for each tab/instrument. What I am noticing is that the alerts generated in the currently active tab are coming through in real-time OK, but the alerts in the hidden/inactive tab DO NOT trigger in the Alerts window UNTIL I activate that tab, and then it will immediately trigger the alert (which may have happened at any time since the last time that tab was active). This is obviously not what we would expect to happen.

      Comment


        #4
        Just noticed this setting in State.SetDefaults:

        IsSuspendedWhileInactive = true;

        Might explain the behaviour Im seeing.

        Comment


          #5
          Hi ours_solaire,

          If you set IsSuspendedWhileInactive to False, are you experiencing the same behavior?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            The IsSuspendedWhileInactive behavior is something that developers should be aware of, as per the note:

            Note: Since events in OnBarUpdate() will not be processed while the indicator is suspended, internal NinjaScript functions such as PlaySound(), Share(), Print(), etc - or any other method that would be used to notify a user of activity will NOT be processed until the indicator has been un-suspended.
            MatthewNinjaTrader Product Management

            Comment


              #7
              PlaySound is not working for me at all. Several calls, not sound. No, speakers are not muted ;-)
              Compile sound is audible.
              IsSuspendedWhileInactive = false;
              AlertSoundFile = @"\sounds\Alert4.wav";
              Print(AlertSoundFile); //outputs as expected: C:\Program Files (x86)\NinjaTrader 8\sounds\Alert4.wav

              Comment


                #8
                Hello CriticalTrader,

                The syntax you provided would only print out "\sounds\Alert4.wav".

                Please modify your string to:

                Code:
                AlertSoundFile = NinjaTrader.Core.Globals.InstallDir + @"\sounds\Alert4.wav";
                
                //or the following below
                AlertSoundFile = @"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert4.wav";
                Zachary G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cre8able, Yesterday, 07:24 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by cocoescala, 10-12-2018, 11:02 PM
                6 responses
                939 views
                0 likes
                Last Post Jquiroz1975  
                Started by gbourque, Today, 06:39 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by benmarkal, Yesterday, 12:52 PM
                3 responses
                23 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X