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 love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          7 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          37 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          45 views
          0 likes
          Last Post bill2023  
          Started by yertle, Today, 08:38 AM
          6 responses
          26 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Working...
          X