Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sending Price in e-mail message

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

    Sending Price in e-mail message

    I have an active strategy which sends a message out when a trade is placed. I would like to include the close price of the bar which triggers the strategy trade entry. This is what I have so far:

    Code:
    SendMail("[email protected]", "[email protected]", "Buy ES Now Last Price = " ,  "");
    I would like to place the price right after "Last Price = ", but I have no idea how to do that. Can you point me at an example of this?
    Thanks
    DaveN

    #2
    Hi DaveN, what you would need to do is save the Closing Bar price value to a variable on the bar your entry condition triggers and then use the variable value in the SendMail() call for your message.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Reply

      Assuming I saves the close value in Variable0, is this the proper format?

      Code:
       SendMail("[email protected]", "[email protected]", "Buy ES  " ,  " Variable0");

      Comment


        #4
        Not Working

        I set up the following test to see if I could get this working but though it compiles it doesn't seem to send any messages out. What should I do differently?
        Thanks
        DaveN

        Code:
         // Condition set 1
                    if (Close[0] > Open[0])
                    {
                        Variable0 = Close[0];
                        SendMail("[email protected]", "[email protected]", "Up Bar", "Close Price = " + Variable0);
                    }

        Comment


          #5
          Hi Dave, it looks good - is this on real-time testing with a signal coming that it did not trigger anything?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Yes, real-time running on CL 10-12 which shoujld have had a message going out on every up bar or down bar. Nothing came out, and I didn't see any errors in the log file.
            DaveN

            Comment


              #7
              Thanks Dave, please retest on Monday with a simple drawing on your conditions added as well, to doublecheck they trigger on your data. If you like, please contact me as well via Help > Mail to Support so I could have a look through the logs / trace generated on Friday. The email setup itself works ok if you test it under Tools > Options > Misc?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Sending price in e-mail message

                Been awhile since I had time to test this. It is working now with the following syntax:

                Code:
                Variable0 = EMADN(E_Period)[0];
                SendMail("[email protected]", "[email protected]", "Long Entry Limit Order at " + Variable0,  "");
                However, I am getting a very long number for the price. Is it possible to truncate the number so it matches the price seen on the chart (2 digits for Crude Oil). I also run this same strategy on the 6E, TF, and ES, Would the same method of truncation work for all of these symbols?

                Finally, since I am running the same strategy of four different symbols is there a method for grabbing the instrument name or symbol and sending it along with the price so I get something that looks like:

                Code:
                Variable0 = EMADN(E_Period)[0];
                SendMail("[email protected]", "[email protected]", "Long Entry Limit Order on " + Variable2, "at " + Variable0,  "");

                Comment


                  #9
                  Hi Daven ,

                  There are functions in the Ninjatrader framework to round values using the specificity of the instrument.

                  in your example , try

                  Code:
                  Variable0  = Instrument.MasterInstrument.Round2TickSize(EMADN(E_Period)[0]);
                  If you want to print the name of the Instrument , just use :

                  Code:
                  Instrument.FullName
                  It will print for example "6E 09-12"

                  So if you want to print only the 2 first caracters use :

                  Code:
                  Instrument.FullName.Substring(0,2)

                  Comment


                    #10
                    Sending price in e-mail message

                    Thanks AAA Trading. I am now getting price, properly formatted (on at least two instruments so far which have triggered), but the name isn't working. I tried both the full name and the subscripted version, but both of them are giving me a number instead of the instrument. Here is the code, followed by the message I am getting:

                    Code:
                    Variable0 = Instrument.MasterInstrument.Round2TickSize(EMADN(E_Period)[0]);
                    				Variable2 = Instrument.FullName[0];
                                    SendMail("[email protected]", "[email protected]", "Long Entry Limit Order on " + Variable2,  "  at " + Variable0);
                    And this is the message I am getting. (fullname in this case should be CL 11-12), but I am getting:

                    (Long Entry Limit Order on 67) at 88.25

                    For Crude I am getting 67, for TF I am getting 84. Is there something I need to do to convert it to text, it seems to be reading a number for the name? I had to add the Indexing [0] to the FullName statement or it wouldn't compile.

                    Thanks

                    DaveN

                    Comment


                      #11
                      Add Expiry?

                      from the NT help searching on 'fullname'

                      Instrument



                      Definition
                      A tradeable instrument.

                      NOTE: The properties in this class should NOT be accessed within the Initialize() method.

                      Methods and Properties
                      Expiry
                      Expiration date of the futures contract
                      FullName
                      Full name of the instrument



                      Originally posted by daven View Post
                      Thanks AAA Trading. I am now getting price, properly formatted (on at least two instruments so far which have triggered), but the name isn't working. I tried both the full name and the subscripted version, but both of them are giving me a number instead of the instrument. Here is the code, followed by the message I am getting:

                      Code:
                      Variable0 = Instrument.MasterInstrument.Round2TickSize(EMADN(E_Period)[0]);
                                      Variable2 = Instrument.FullName[0];
                                      SendMail("[email protected]", "[email protected]", "Long Entry Limit Order on " + Variable2,  "  at " + Variable0);
                      And this is the message I am getting. (fullname in this case should be CL 11-12), but I am getting:

                      (Long Entry Limit Order on 67) at 88.25

                      For Crude I am getting 67, for TF I am getting 84. Is there something I need to do to convert it to text, it seems to be reading a number for the name? I had to add the Indexing [0] to the FullName statement or it wouldn't compile.

                      Thanks

                      DaveN

                      Comment


                        #12
                        Sending Price in E-Mail continued

                        It is working great now. Instead of using a variable to transmit the Instrument name I just used the Instrument.FullName in the statement. I then used that variable to capture the closing price of the bar I got the order entry signal on so now the message I get is:

                        Long Entry Limit Order on CL 11-12 at 88.31 Current Price is 88.41.

                        Here's the code I used in case anyone else is interested. Now I want to work on sending a message when the entry order fills and when the price target fills. Since I think that is going to be onExecution programming, I am going to have to study a bit, (unless of course you have an example of such a beat).

                        SendMail("[email protected]", "[email protected]", "Long Entry Limit Order on " + Instrument.FullName, " at " + Variable0 + " Current Price is " + Variable2);
                        Thanks for your help in getting this fixed and running. I really appreciate it.

                        DaveN

                        Comment


                          #13
                          Why this one wouldn`t work for you?

                          Code:
                          + Math.Round  ( Close[0], 4 )

                          Comment


                            #14
                            Originally posted by outsource View Post
                            Why this one wouldn`t work for you?

                            Code:
                            + Math.Round  ( Close[0], 4 )
                            The inappropriately named round2ticksize, handles all instruments properly (such as pips and ticks,or any other instruments with different rounding requirements).

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by r68cervera, Today, 05:29 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post r68cervera  
                            Started by geddyisodin, Today, 05:20 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post geddyisodin  
                            Started by JonesJoker, 04-22-2024, 12:23 PM
                            6 responses
                            35 views
                            0 likes
                            Last Post JonesJoker  
                            Started by GussJ, 03-04-2020, 03:11 PM
                            12 responses
                            3,241 views
                            0 likes
                            Last Post Leafcutter  
                            Started by AveryFlynn, Today, 04:57 AM
                            0 responses
                            7 views
                            0 likes
                            Last Post AveryFlynn  
                            Working...
                            X