• 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

How to set alarm after a candle closes

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

    How to set alarm after a candle closes

    good morning, does anybody knows how to set a sound alert 240 seconds after a candle closes?

    Andres

    #2
    You use a Timer from the System.Timers namespace.

    NB there are other timers in System.Threading.Timer, System.Windows.Forms.Timer, System.Web.UI.Timers and System.Windows.Threading.DispatcherTimer make sure you import System.Timers.Timer and not one of the other namespaces

    Be sure to set AutoReset to false or it will repeat every 240 seconds

    Code:
    Timer timer = new Timer(TimeSpan.FromSeconds(240).TotalMilliseconds);
    timer.AutoReset = false;
    timer.Elapsed += (o, args) =>
    {
           PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Alert1.wav"
    	timer.Dispose();
    };
    
    timer.Start();

    Comment


      #3
      Originally posted by reach4thelasers View Post
      You use a Timer from the System.Timers namespace.

      NB there are other timers in System.Threading.Timer, System.Windows.Forms.Timer, System.Web.UI.Timers and System.Windows.Threading.DispatcherTimer make sure you import System.Timers.Timer and not one of the other namespaces

      Be sure to set AutoReset to false or it will repeat every 240 seconds

      Code:
      Timer timer = new Timer(TimeSpan.FromSeconds(240).TotalMilliseconds);
      timer.AutoReset = false;
      timer.Elapsed += (o, args) =>
      {
             PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Alert1.wav"
      	timer.Dispose();
      };
      
      timer.Start();
      Hi, thank you for your help, sorry im not good at this, could you kindly make it a .cs file,
      would be much appreciated

      Andres

      Comment


        #4
        I'm sure if you really apply yourself you will figure it out. Open the ninjascript editor, make a new indicator, and paste that into OnBarUpdate

        Comment


          #5
          Originally posted by reach4thelasers View Post
          I'm sure if you really apply yourself you will figure it out. Open the ninjascript editor, make a new indicator, and paste that into OnBarUpdate
          I am trying, this error appears

          BTW i do need it to repeat in that interval (after a 5 min candle closes, 240 seconds, activate the sound alert) so i did set rearm true

          thank you
          Attached Files
          Last edited by andddres1; 06-14-2017, 10:35 AM.

          Comment


            #6
            Hello,

            Thank you for posting.

            In the image it looks like you are missing a ); at the end of the PlaySound line causing an error.

            After adding the ); it should compile from what I can see.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              whoops my-bad on the missing semi-colon. I copied and pasted it straight of the Ninjatrader docs onto the forum.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by memonolog, Today, 07:56 AM
              0 responses
              2 views
              0 likes
              Last Post memonolog  
              Started by tdawson11, Today, 07:48 AM
              0 responses
              2 views
              0 likes
              Last Post tdawson11  
              Started by pstrusi, Today, 07:39 AM
              0 responses
              5 views
              0 likes
              Last Post pstrusi
              by pstrusi
               
              Started by vantojo, 06-19-2019, 04:06 PM
              6 responses
              34 views
              0 likes
              Last Post vantojo
              by vantojo
               
              Started by Mike661, Today, 07:22 AM
              0 responses
              7 views
              0 likes
              Last Post Mike661
              by Mike661
               
              Working...
              X