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

Setting up Strategy outgoing Email

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

    Setting up Strategy outgoing Email

    Convert.ToString(NinjaTrader.Cbi.Instrument.GetIns trument(),

    I would also like the Machine ID if possible,

    How to I get the instrument trade sent in the email or alert- i tryed the above
    Thanks


    #2
    Hello DTSSTS, thanks for your question.

    I made this indicator in the past that emails the user when an execution occurs on the account:

    This indicator will email the specified email address when an execution occurs on the selected account.


    The machine ID can be accessed with Cbi.License.MachineId.

    Please let me know if you have any questions about this.

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      So can i just use that indicator in my strategy builder

      i also would need to embed an ToEmail Address not to be modified

      Exactly how do i apply this indicator in a strategy builder,
      Left side set email and right side true or = 1

      or should left side indicate the trade took place and then right side list email address
      Last edited by DTSSTS; 08-10-2020, 11:56 AM.

      Comment


        #4
        when using the strategy builder i cant seem to get the instrument and the machineid to do anything but send a text

        with @" Cbi.Instrument.GetInstrument() because I have @ instead of Conver.ToString

        SendMail(@"[email protected]", autotrade, Convert.ToString(Position.MarketPosition) + @" Cbi.Instrument.GetInstrument() + Convert.ToString(Position.Quantity) + " " + Convert.ToString(Position.AveragePrice) + @" Cbi.License.MachineId");
        }


        also need to figure out how to send email on order filled OR send Once rather than BarsSinceEntryExecution as the email sends multiple times until the next bar is open
        Last edited by DTSSTS; 08-10-2020, 04:33 PM.

        Comment


          #5
          Hello DTSSTS, thanks for your reply.

          This can not be done in the builder. It is generating string literals and not system code for the actual property. The script needs to be unlocked to get this to work.

          Please let me know if I can assist any further.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            that being said, is this correct script

            SendMail(@"[email protected]", autotrade, Convert.ToString(Position.MarketPosition) + Convert.ToString(Cbi.Instrument.GetInstrument()) + Convert.ToString(Position.Quantity) + Convert.ToString(Position.AveragePrice) + Convert.ToString(Cbi.License.MachineId);


            Thanks

            ALSO can your indicator be used in strategy builder, you never said, if so, what goes where as I ask in earlier post

            Comment


              #7
              Hello DTSSTS, My apologies, the forum was down for some time.

              All clients that are writing scripts should be able to debug and test lines of code on their own. To test if the line of code you provided works, put it into the NinjaScript editor, make sure it compiles first, then check the output of the line of code.

              The script I gave can not be used in the builder, it runs on a chart. Whatever account is selected in the properties, it will send an email containing details on the executions that occur on the account.

              Kind regards.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                thanks for the info

                Comment


                  #9
                  Chris I have finally unlock our code and editing the send email line of code, I still have an error (likely just a comma or something little)

                  the error states: "No overload for method 'getInstrument' takes 0 arguments" CS1501

                  here is my code, thanks

                  SendMail(@"[email protected]", @"ATSAutoTrade", Convert.ToString(Position.MarketPosition) + Convert.ToString(Cbi.Instrument.GetInstrument()) + Convert.ToString(Position.Quantity) + Convert.ToString(Position.AveragePrice) + Convert.ToString(Cbi.License.MachineId));

                  Comment


                    #10
                    Hello DTSSTS,

                    When you get a compile error stating the "No overload for method" this would mean your syntax is incorrect. We are also being advised that GetInstrument does not take 0 parameters. Looking at your code, you are calling GetInstrument without any parameters.

                    Resolving would involve checking how the syntax should be written. You can check the documentation to see how this method would be used.

                    https://ninjatrader.com/support/help...instrument.htm

                    We look forward to assisting.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      I do not follow, we are not trying to define the instrument, but retrieve the instrument as the instrument could be ONE of any

                      Convert.ToString(Cbi.Instrument.GetInstrument())

                      I am only looking for what goes () between the brackets to have the Instrument symbol be included in the email

                      all other items are being included

                      any help from any one is appreciated
                      Last edited by DTSSTS; 01-22-2021, 03:09 PM.

                      Comment


                        #12
                        Hello DTSSTS,

                        Do you mean you want to fetch the name of the Instrument that the script is applied to? You can use Instrument.FullName.

                        Instrument.FullName - https://ninjatrader.com/support/help...t_fullname.htm

                        Instrument.GetInstrument(string instrumentName) would be used to get an Instrument object by specifying the name of the instrument. You are using this in your code, and you are not providing the instrument name parameter, so the compiler gets and error and tells you the syntax is incorrect.

                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          i tried several ways to use Instrument.FullName (I would rather have the symbol, but name may have to work) the help guide is not detail enough

                          Convert.ToString(Cbi.Instrument.GetInstrument()) +

                          what do i replace this with, I have tried many options without success

                          thanks for the help

                          Comment


                            #14
                            Jim I did get Instrument.FullName to work,

                            example of what I get for Home Depot for instance is

                            ShortHD Default100283.22354machineidnumber79D85FE

                            also with the help guide where is the section that covers how to get spaces between each field that is being emailed

                            FOR ANYONE WISH TO SEND EMAIL FROM STRATEGY - THE BELOW DOES WORK, if we get the spaces in I will post update

                            SendMail(@"[email protected]", @"ATSAutoTrade", Convert.ToString(Position.MarketPosition) + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + Convert.ToString(Position.Quantity) + Convert.ToString(Position.AveragePrice) + Convert.ToString(Cbi.License.MachineId));


                            Trying for message

                            Short HD Default100 283.22 354machineidnumber79D85FE

                            thanks for all the help

                            Comment


                              #15
                              Hello DTSSTS, thanks for your reply.

                              You will need to add the spaces to the string manually e.g.

                              Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " " + Convert.ToString(Position.Quantity) //and so on

                              Please let me know if I can assist any further.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              11 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              14 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X