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

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,
    BertrandNinjaTrader Customer Service

    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 trilliantrader, 04-18-2024, 08:16 AM
          7 responses
          27 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by samish18, 04-17-2024, 08:57 AM
          17 responses
          64 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by rocketman7, Today, 02:12 AM
          2 responses
          17 views
          0 likes
          Last Post rocketman7  
          Started by briansaul, Today, 05:31 AM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PaulMohn, Today, 03:49 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X