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 Questions

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

    SendMail Questions

    Hello,

    I want to send a text message to a phone using this command. So I have added a SendMail () to my script using the ninjatrader address for the From Email Address and my [email protected] for the To Email Address. I have a few questions regarding using the SendMail command.

    1) Do I also have to add an Alert to the script for this to work?
    2) If I use the ninjatrader as the From Email address, do I have to change any of the email settings under Tools - Options - Misc or do I just leave it as the default (empty)
    3) Could I also send texts to my phone by using the Verizon email address as the From Email address? I'm assuming I would just have to modify the email options to use the Verizon settings in place of the ninjatrader ones?
    4) Does the SendMail command only work with real-time data, or does it work during Replay? Is there a process for testing messages?

    Thank you,

    Lee

    #2
    Hello lee612801,

    Thank you for your inquiry.

    To answer your questions:
    1. You would not need an Alert to have this method call function. As long as SendMail() is triggered in the code, it will execute.
    2. You would want to specify your own email address in the from field and change those SMTP settings. You would be able to find various SMTP settings for different providers at this link: http://ninjatrader.com/support/forum...d.php?p=262008
    3. You would be able to use your Verizon email address to send a text message to your phone provided you have the correct SMTP settings NinjaTrader can use to send an email alert from that Verizon email account.
    4. SendMail() will work on a Market Replay connection as it is simulating "live" data while you are going through the playback.

      You could do something simple like . . .
      Code:
      if (Close[0] > Close[1])
           SendMail("[email protected]", "[email protected]", "subject", "body");
      . . . to test if a mail message is sent. I suggest adding some sort of counter to prevent yourself getting spammed by messages every time the close of the current bar is greater than the close of the previous bar.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hi Zach,

      Thank you very much! Appreciate the thorough response. I will give this a try tonight.

      Regards,

      Lee

      Comment


        #4
        How would you capture the ATM information once an order is triggered

        Comment


          #5
          I am looking to create an alert which emails the order info

          Comment


            #6
            Hello brucelevy,

            Thank you for your inquiry.

            Please take a look at this link in the NinjaTrader help guide for ATM Strategy Monitoring methods that you can use to obtain various types of information about the ATM Strategy you would like to get info for.

            For example, you can create a string[] array called entryOrder that will be assigned to the GetAtmStrategyEntryOrderStatus() method call's return:

            Code:
            string[] entryOrder = GetAtmStrategyEntryOrderStatus("orderId");
            You can then use a String.Format to combine the three strings into one, assign it to a variable, and pass this variable to your send mail:
            Code:
            string atmOrderInfo = String.Format("Avg fill price: {0}, Filled amount: {1}, Current state: {2}", entryOrder[0], entryOrder[1], entryOrder[2]);
            
            SendMail("[email protected]", "[email protected]", "subject", atmOrderInfo);
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              I'm getting this error: Operator '>' cannot be applied to operands of type 'string' and 'int'
              and
              The name 'entryOrder' does not exist in the current context..


              #region Variables
              private string atmStrategyId = string.Empty;
              private string orderId = string.Empty;
              string atmOrderInfo = String.Format("Avg fill price: {0}, Filled amount: {1}, Current state: {2}", entryOrder[0], entryOrder[1], entryOrder[2]);

              #endregion

              /// <summary>
              /// This method is used to configure the strategy and is called once before any strategy method is called.
              /// </summary>
              protected override void Initialize()
              {
              CalculateOnBarClose = false;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {

              // Email
              string[] entryOrder = GetAtmStrategyEntryOrderStatus("orderId");
              if (entryOrder.Length > 0)
              {
              SendMail("from", "to", "subject", atmOrderInfo);
              }

              Comment


                #8
                Hello brucelevy,

                It looks like you are creating your entryOrder string array after the String.Format. entryOrder[0], entryOrder[1], and entryOrder[2] do not exist at that point, which is why you are receiving the "The name 'entryOrder' does not exist in the current context" error.

                I am not sure why you are getting the "Operator '>' cannot be applied to operands of type 'string' and 'int'" error. Please check the line number where the error appears and check to see if you are comparing a string to an int.

                The only use of a ">" symbol I see is in if (entryOrder.Length > 0) which is a valid comparison. Perhaps that error will disappear once you recompile after placing your entryOrder variable before string atmOrderInfo.
                Zachary G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                9 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                14 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                13 views
                0 likes
                Last Post strategist007  
                Started by StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,983 views
                3 likes
                Last Post jhudas88  
                Working...
                X