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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          581 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          338 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X