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

any pause command

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

    any pause command

    Hi,

    I am trying to have to play two audio files based on certain condition. However, only 2nd file will be played as it ignored the 1st file. Thus I'm thinking if there is a pause command in between the two statements, it should be ok.

    if (condition1) Alert("audio1.wav");
    if (condition2) {
    pause(<5 seconds>); // assume the audio1.wav is about 5 seconds
    Alert("audit2.wav");
    }

    OR there is a better way!

    Regards,
    Toyogo

    #2
    You NEVER should pause your NinjaScript, since this could lock up NT. You could try playing around with a timer based approach like here: http://www.ninjatrader-support.com/v...ead.php?t=5965

    Comment


      #3
      Hi,

      The example provided is too complicated which I don't think it applied to my case. Anyhow, I only want a simple timer. I used to use the loop command such as:

      for (i=0 to 1000) i--; this will provide a simple delay for few seconds. However, as this method is depending on the CPU speed, it is not accurate at all.

      There are programming languages provide simple command like delay(5) to set timer for 5 seconds. I'm looking for such command in NT

      Regards,
      Toyogo

      Comment


        #4
        Please see my post below: you NEVER should code a "busy wait" but code a timer based approach as in link I provided. If it's too complex, then I suggest accepting the limitation you experienced in your initial post.

        Comment


          #5
          Don't know if this will work for you, and don't know if it would cause a problem in NT (maybe Dierk could comment).

          System.Threading.Thread.Sleep(3)

          This example would insert a 3 millisecond delay.

          Comment


            #6
            This is exactly what you should NOT do, since it locks up NT.

            Comment


              #7
              Hi,

              Thanks. will take your advise!

              Regards,
              Toyogo

              Comment


                #8
                Originally posted by NinjaTrader_Dierk View Post
                This is exactly what you should NOT do, since it locks up NT.
                Does this mean that all NinjaScripts are single threaded? For example, if I have a global variable which I change in one call (say OnOrderUpdate) there is no danger of effecting another thread running somewhere else (say in OnBarUpdate) ?

                Comment


                  #9
                  As of now that is correct. But don't rely on that, but apply .NET locking, since this might change with NT7.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by FrazMann, Today, 11:21 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post FrazMann  
                  Started by geddyisodin, Yesterday, 05:20 AM
                  8 responses
                  52 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cmtjoancolmenero, Yesterday, 03:58 PM
                  10 responses
                  36 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by DayTradingDEMON, Today, 09:28 AM
                  4 responses
                  24 views
                  0 likes
                  Last Post DayTradingDEMON  
                  Started by George21, Today, 10:07 AM
                  1 response
                  19 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Working...
                  X