Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 audio alert - statement expected?

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

    NT7 audio alert - statement expected?

    hi,
    Dont know the first thing about programming but assumed this would be easy bearing in mind the 2 pieces of code im playing with are almost identical. Audio alert works fine on one of the pieces of code but I dont understand why it doesn't work on the other.

    It says that a statement is expected?

    Hopefully the picture explains it.

    I use the 'playsound' piece of code to the top indicator and it works

    I use it in what appears to be the exact same way in the other code in the other indicator (bottom), and it gets an error messgae?

    Why is that? How do i fix it?

    thanks
    Attached Files

    #2
    subterfuge, thanks for post here - our new NinjaScript trainee will take a look at your inquiry and then reply back here with his recommendations to resolve.

    Thanks,

    Comment


      #3
      Hello subterfuge,

      The code after the if statement needs to be grouped together with { } brackets or else the compiler will get confused. You will want to do this anytime you want more than one line of code to be associated with the if statement.

      Also, in the top code you highlighted, the PlaySound() would be called if the condition is met, but the DrawText() will always be called because it's not grouped into the if statement.

      In your case, you will want to format the code in both indicators like this:
      Code:
      if (curhigh < prevhigh + offset && curhigh > prevhigh - offset)
      {
      	DrawText("DT" + CurrentBar, "DT", barsback, High[barsback] + toffset, Color.Gold);
      	PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\doubletopbottom.wav");
      }
      For more information on if-else statements in C# please see this link: http://msdn.microsoft.com/en-us/library/5011f09h.aspx

      Please give this a try and let me know if that works for you.
      DexterNinjaTrader Customer Service

      Comment


        #4
        thanks, Dexter. You're a star.

        Comment


          #5
          My pleasure!

          If you run into any other issues just let us know.
          DexterNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          175 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          91 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          130 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          210 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          186 views
          0 likes
          Last Post CarlTrading  
          Working...
          X