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

SendMail & PlaySound

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

    SendMail & PlaySound

    Hi all -
    I have created a condition for an alert to go short and one to go long - both conditions play the same .wav file and send emails to the same address (subject is different as one is short the other long), but that is the only difference.
    The short condition is coded first and works fine - the long condition is second and does not work. Can anybody tell me why? Code below:

    if (Falling(TrendSMA) && Tma[0] < TrendSMA[0])
    {
    DrawArrowDown();
    DrawText();
    PlaySound(@"Siren-AirRaid.wav");
    SendMail(@"********@gmail.com", "********@gmail.com", "Zone Trader Alert SHORT", "");
    }


    if (Rising(TrendSMA) && Tma[0] > TrendSMA[0])
    {
    DrawArrowUp();
    DrawText();
    PlaySound(@"Siren-AirRaid.wav");
    SendMail(@"*********@gmail.com", "********@gmail.com", "Zone Trader Alert LONG", "");
    }

    *Obviously DrawArrow & Text are okay/work fine - I just haven't repeated all the code here.

    Thanks in advance.

    Ben.

    #2
    Hello stocktraderbmp,

    Are you checking the values of the "Rising(TrendSMA)", "Tma[0]", and the "TrendSMA[0]" to make sure that your condition is going to be true using the Print() method?

    Here is a link to our support forums that goes over how to debug your code which comes in handy when writing custom code to see how your strategy is being processed.
    http://www.ninjatrader.com/support/f...ead.php?t=3418

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC
      Thanks for coming back to me so quickly;

      As I said in my post the first condition works perfectly as does the DrawArrow and DrawText so yes the conditions are all true otherwise the Draw.... functions would not be 'Draw..ing' This is obviously the case for both short and long scenarios - the only part that fails is the PlaySound and SendMail on the second condition despite it being a perfect copy of the first condition - with the exception of the subject line.

      I have looked through the help files but have not been able to uncover anything - I was wondering if these need a 'Tag' as per DrawText etc but can't find mention of it.

      Am I only able to use this once ? Do I need to use extra bracketing somewhere?

      Any other suggestions?

      Comment


        #4
        Hello stocktraderbmp,

        Do you see an error message in the Log tab of the Control Center after your Rising condition is true?

        If not, can you send a toy* NinjaScript code replicating the behavior so that I may look into this. You can either Export it as a Source File using the step from our Help Guide at the link below or just send the ".cs" file that is going to be located in the (My) Documents -> NinjaTrader 7 -> bin -> Custom -> Strategy folder to Support [at] ninjatrader [dot] com with ATTN: JC with reference to this thread.
        http://www.ninjatrader.com/support/helpGuides/nt7/index.html?export.htm


        Happy to be of further assistance.

        *Toy - basically a stripped down version of code that isn't necessarily the whole logic; making it easier to identify lines of code.
        JCNinjaTrader Customer Service

        Comment


          #5
          Nothing in the log - will send .cs file when I get a chance later this morning.

          Thanks;

          Ben.

          Comment


            #6
            Try several things..

            1) print statements before and after each line to the output window.
            2) use some exception handling to see if something is caught.



            Originally posted by stocktraderbmp View Post
            Hi JC
            Thanks for coming back to me so quickly;

            As I said in my post the first condition works perfectly as does the DrawArrow and DrawText so yes the conditions are all true otherwise the Draw.... functions would not be 'Draw..ing' This is obviously the case for both short and long scenarios - the only part that fails is the PlaySound and SendMail on the second condition despite it being a perfect copy of the first condition - with the exception of the subject line.

            I have looked through the help files but have not been able to uncover anything - I was wondering if these need a 'Tag' as per DrawText etc but can't find mention of it.

            Am I only able to use this once ? Do I need to use extra bracketing somewhere?

            Any other suggestions?

            Comment


              #7
              Will look at it again at the close

              Thanks again Sledge.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by gravdigaz6, Today, 11:40 PM
              0 responses
              6 views
              0 likes
              Last Post gravdigaz6  
              Started by MarianApalaghiei, Today, 10:49 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by XXtrader, Today, 11:30 PM
              0 responses
              4 views
              0 likes
              Last Post XXtrader  
              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
              9 views
              0 likes
              Last Post funk10101  
              Working...
              X