Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SendMail Query

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

    SendMail Query

    This is more a programming query:
    I often use SendMail() in my strategies, what sintax should I use to receive message with more than 1 line in the message field?

    For example now I am receiving this message:
    Code:
    SendMail("my@email","my@email","Trade Recap","You entered Long, Good Luck!");
    That is displayed this way:

    You entered Long, Good Luck!
    How can I get it to be displayed this way:
    You entered Long,

    Good Luck!
    Thanks,

    #2
    Hello sburtt,

    Inside of your String of the body text you would put a "\r\n" to create a new line inside of the string for your message.

    For example:

    string test = "This is a Test.\n\rAnd now it is over.";

    This will output like:

    Code:
    This is a Test.
    And now it is over.
    Last edited by NinjaTrader_JC; 08-09-2013, 07:13 AM.
    JCNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JC View Post
      Hello sburtt,

      Inside of your String of the body text you would put a "\n\r" to create a new line inside of the string for your message.

      For example:

      string test = "This is a Test.\n\rAnd now it is over.";

      This will output like:

      Code:
      This is a Test.
      And now it is over.
      http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx
      1.
      I am actually having a problem doing this, it works fine with text, but what If need to add a another string with my execution price, for example lets say that i want to display the email text this way:

      Order Long was filled at:
      512.50
      Good luck!
      How do I pull out the price 512.50 from the following string?

      Code:
      protected override void OnExecution(IExecution execution)
      {
         // put the execution details into string format
          string exec_s = execution.ToString();
      }
      2. and would the answer to 1. change if insted of using the code above i get the price from something like this i have elsewhere in my script?

      Code:
      +Convert.ToDecimal(enterPosition).ToString("###0.00")
      Thanks for your help
      Last edited by sburtt; 08-08-2013, 02:02 PM.

      Comment


        #4
        Hello sburtt,

        Well an easier way to get just the price that your order was filled would be to use the "execution.Price".



        As for the adding in the price, could you try something like:

        Code:
        SendMail("my@email","my@email","Trade Recap","Order Long was filled at:\r\n"+exec_s+"\r\nGood Luck!");
        JCNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JC View Post
          Hello sburtt,

          Well an easier way to get just the price that your order was filled would be to use the "execution.Price".



          As for the adding in the price, could you try something like:

          Code:
          SendMail("my@email","my@email","Trade Recap","Order Long was filled at:\r\n"+exec_s+"\r\nGood Luck!");
          ok working fine now, in the previous reply you had posted \n\r rather than \r\n and that was giving error, but all good now. Thanks!

          1 last thing, is there a way to print the market position status prior execution and after execution? I would need the output to be long/short or flat, could you pls advise on how I can get this? thanks

          Comment


            #6
            Hello sburtt,

            My apologizes, I have changed my post to reflect that as well.

            As for checking the position before OnExecution() the best way that I can think of would be to create a variable and set the variable to Position.MarketPosition inside of OnBarUpdate() so that you may check it inside of OnExecution() and then you may also get the Position.MarketPosition to tell you what your new position is.

            JCNinjaTrader Customer Service

            Comment


              #7
              in the OnExecution() section
              would (Position.MarketPosition).toString() return flat/long/short?

              furthermore, why do I need to set a variable for Position.MarketPosition? Doesn't the strategy know I am long after a long entry is executed?

              Thanks,

              Comment


                #8
                Hello sburtt,

                Yes, in OnExecution you may use the Position.MarketPosition but this will return the what MarketPosition you are in as of the Execution.

                If you would like to see what position you were prior to the Execution in OnExecution you would have to use a variable to store that value.
                JCNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

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