Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

email on position entry

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

    email on position entry

    Is there a way to set NT to send an email when a position is entered instead of after every OCO? Or am I misunderstanding how the email string actually works?

    #2
    RDPoS, this is definitely possible. You can use the OnPositionUpdate() method to track changes in position to send out emails whenever your position changes. What code are you currently using to send these emails?
    AustinNinjaTrader Customer Service

    Comment


      #3
      I was using strategy wizard to do the dirty work. I was also hoping to send price info in the email.

      Comment


        #4
        You could email the Position.AvgPrice from the OnBarUpdate() for example, if you want to access the individual executions you would need to work in OnExecution() then.

        Comment


          #5
          How about the following?

          Code:
          		protected override void OnPositionUpdate(IPosition position)
          		{
          			if (position.MarketPosition == MarketPosition.Long)
          			{
          			    SendMail("NT6.5", "[email protected]", "Long position entered", position.AvgPrice);
          			}
          			if (position.MarketPosition == MarketPosition.Flat)
          			{
          			    SendMail("NT6.5", "[email protected]", "Position Closed", position.AvgPrice);
          			}
          		}

          Comment


            #6
            Hello,

            Position.AvgPrice only works on the entry condition.

            When you are flat Position.AvgPrice will be 0.

            The only way to get the price of the close would be work in OnExecution() and would take some more advanced coding.

            You can use this sample to do this:



            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment


              #7
              IS there a way to get an email when the connection to the broker is lost? Kind of a remotely critical notification....

              Comment


                #8
                Yes, this is possible. You can work in OnConnectionStatus() method to monitor for disconnections.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  The email is still not sent from the previously posted code

                  Code:
                  protected override void OnPositionUpdate(IPosition position)
                  		{
                  			if (position.MarketPosition == MarketPosition.Long)
                  			{
                  			    SendMail("NT6.5", "[email protected]", "Long position entered", "Long position entered");
                  			    SendMail("NT6.5", "[email protected]", "TEST Long position entered", "Long position entered");
                  			}
                  			if (position.MarketPosition == MarketPosition.Flat)
                  			{
                  			    SendMail("NT6.5", "[email protected]", "Position Closed", "Position Closed");
                  			    SendMail("NT6.5", "[email protected]", "TEST Position Closed", "Position Closed");
                  			}
                  		}

                  Comment


                    #10
                    Would you see any log errors? Is the email feature generally working out for you?

                    Comment


                      #11
                      I have never gotten it to work yet.

                      Comment


                        #12
                        Please also try try changing the SMTP outgoing mail server to use your own ISP's mail server.

                        You can set this information via the Control Center window Tools > Options > Misc.

                        Comment


                          #13
                          Ok, I updated the info for gmail as per: http://mail.google.com/support/bin/a...n&answer=13287

                          The following are the Gmail SMTP server and port settings for sending mail through Gmail from any email client program:
                          under Outgoing mail, set Gmail SMTP server address: smtp.gmail.com
                          Configure Gmail SMTP user name as: your full Gmail address (including @gmail.com) Google Apps users may have to enter username@your_domain.com
                          Configure Gmail SMTP password as: Your Gmail password
                          Configure Gmail SMTP port as: 465 or 587
                          Configure Gmail SMTP TLS/SSL required as: yes

                          Obviously there is no SSL setting that I can find.

                          NT stops responding and crashes. Why?


                          Last edited by RDPoS; 11-12-2010, 07:15 AM.

                          Comment


                            #14
                            The second time, I tried after NT shut down, it shut down again.

                            The third time I tried I got the following error message

                            Comment


                              #15
                              Unfortunately SSL will not work for NT 6.5 - we've added this option for NT7.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              639 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              366 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              107 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              569 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              572 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X