• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sending E-mail upon order execution

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

    #16
    3+4 is a clear indicator that there is a coding issue in your logic, since email sending works in general. I suggest working the Print() statement for now and finish implementation of your strategy and then you may add SendMail() statements right after the Print() statements (not replace, to see that mails come in sync with the Print() statements).
    DierkNinjaTrader Customer Service

    Comment


      #17
      Thx for the response Dierk......hope you guys dont think I am being a pain on this !

      In your note, are you suggesting that I have to wait until you fix the coding issue, before I will be able to use this function at all? or that if I use the Print () statement prior to the SendMail () function that should work.....since trying this the morning it doesn't. See below:

      if(x == false)
      { Print(
      "BUY BUY BUY");
      SendMail(
      "[email protected]", "[email protected]", "BUY BUY BUY", "");
      Print(
      "BUY BUY BUY");
      x=
      true;
      }.


      Also, can I assume that it will be 3-4 weeks before a fix will be in place?
      many thx
      David

      Comment


        #18
        >> are you suggesting that I have to wait until you fix the coding issue, before I will be able to use this function at all?
        No, we are not aware of any issue. I fixed the typo in my post. You are on the right track with your code snippet below.
        DierkNinjaTrader Customer Service

        Comment


          #19
          thx.
          Current issue is that using a simulated data feed (because it is the w/e), I am unable to send any emails whatsoever from a strategy.....even one that is as simple as: SendMail() with no other code.
          I noted this problem last w/e, but it was suggested there was a bug in my code.

          This is the possible reason why when testing the snippet below over the w/e, Print() works by itself, but Print(); SendMail() only Prints.

          thx for your help.
          DG

          Comment


            #20
            a) I suppose you have set up your SMTP server at Tools->Options->Misc and tested that sending mails works ok, no?
            b) you double checked that the mail address you are using is valid, no?

            I just tested simple strategy below on the sim feed (5 tick chart) and it works as expected -> mails are sent as sim (live) data comes in:
            Code:
                    protected override void OnBarUpdate()
                    {
                        if (Historical)
                            return;
                        
                        if (CrossAbove(SMA(5), SMA(20), 1))
                        {
                            Print("EnterLong");
                            SendMail(..., "EnterLong", "EnterLong");
                            EnterLong();
                        }
                        else if (CrossBelow(SMA(5), SMA(20), 1))
                        {
                            Print("EnterShort");
                            SendMail(..., "EnterShort", "EnterShort");
                            EnterShort();
                        }
                    }
            DierkNinjaTrader Customer Service

            Comment


              #21
              thx for your respons.

              I have now resolved why no e-mail has been sent - it was because the 'Exclude weekends' was set to true !!!!

              So now I can send copious e-mails simulataneously through the SIM feed.
              I am still unable to do this just the once, however, using a filter.

              Pls try the following --- it executes the Print() command, but not the SendMail() command. I have been at this now for over two weeks.....I seem to be getting nowhere!

              Is it how I set up the private bool expression?
              Even if I change it to an int, I get the same result.

              privatebool x = false;
              #endregion

              ///<summary>
              /// This method is used to configure the strategy and is called once before any strategy method is called.
              ///</summary>


              protectedoverridevoid OnBarUpdate()
              {
              // Condition set 1
              if(x == false)
              {
              Print(
              "BUY");
              SendMail(
              "[email protected]", "[email protected]", "BUY", "");
              Print(
              "BUY");
              }
              x=
              true;

              Comment


                #22
                This then is a bug on your strategy code (since SendMail as per my sample works with your SMTP setup). Unfortunately, due to bandwidth reasons, we are unable to provide support down to the level of actual coding/revising strategies. You might consider contacting a NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm

                Thanks for your understanding.
                DierkNinjaTrader Customer Service

                Comment


                  #23
                  Your example sends numerous emails per order execution.
                  Hence the need for a filter.
                  Hence my example in the prior thread below.

                  I do not understand how if the following prints "BUY" twice but does not send an e-mail means that there is fault in my code........there is nothing in the log either which suggests that it doesn't even attempt to send an e-mai.

                  Print()
                  SendMail()
                  Print()

                  I will ask you again - pls try what I have done below.
                  If you get it to work by changing the code then fine I will contact a consultant.

                  PS I will not give up

                  thx
                  David

                  Comment


                    #24
                    In post #12 I stated that SendMail() does not work on historical data. I suspect this is the logic flaw in your code.

                    Your code executes on the first bar only which is likely historical, try adding the code below to resolve your issue.

                    if (Historical)
                    return;
                    RayNinjaTrader Customer Service

                    Comment


                      #25
                      Ray / Dierk
                      Thx for your patience & on-going support in trying to resolve this issue.
                      In the end yesterday I resorted to contacting a NinjaScript consultant.
                      Best cash I have spent in a long time.
                      Code delivered in less that 18 hours at a very reasonable price --- with a very positive response.
                      Should have done this 4 weeks ago............still at least I have an improved understanding of how your code & NT strategies work.

                      thx
                      David

                      Comment


                        #26
                        Thanks for your feedback. Glad this approach made sense for you.
                        DierkNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by James108, Today, 06:09 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post James108  
                        Started by RandanAL, Today, 05:13 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post RandanAL  
                        Started by timko, Today, 05:06 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post timko
                        by timko
                         
                        Started by ballboy11, Today, 01:04 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_PaulH  
                        Started by Linda1507, Today, 01:22 PM
                        2 responses
                        15 views
                        0 likes
                        Last Post Linda1507  
                        Working...
                        X