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

Need email alert to give name of instrument

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

    Need email alert to give name of instrument

    I run 2 different strategies on about 10 instruments in four different time frames. When I get an email I have to manually scan the instruments to see which one triggered the alert. Is there an easy way to get the strategy to tell me which instrument triggered the alert? Thanks!

    #2
    In your strategy you could use SendMail().

    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Using sendmail now

      That is what I am using now to send the email but the message states "Long startegy triggered" I would like it to say long strategy triggered on USDJPY in 30 min time frame for example. Is there a way to get NT to "get the name of the instrument and automatically out it in the email. I am not aware of a way to get sendmail to do this. Thanks!

      Comment


        #4
        Code:
        SendMail("[email protected]", "[email protected]", "Trade Alert", "Long strategy triggered on " + Instrument.MasterInstrument.Name + " in " + Bars.Period.Value + "-" + Bars.Period.Id + " time frame.");
        The body of your email would end up as something like this:
        "Long strategy triggered on ER2 in 1-Minute time frame."
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks

          Thanks for your help!

          Comment


            #6
            The NinjaTrader documentation people may already have done this, but if not, I'd like to suggest this as a good example to add to the Help under SendMail.

            It would be nice to see this example of Josh's there, in addition to the somewhat less complex example that's already there.

            Also, I know its a matter of personal preference, but I like this alternate, but equivalent format that could be added as well:

            Code:
            SendMail("[email protected]", "[email protected]", "Trade Alert", String.Format("Long strategy triggered on {0} in {1}-{2} time frame", Instrument.MasterInstrument.Name, Bars.Period.Value, Bars.Period.Id ));
            Adding little nuances like this could help people who are trying to get up to speed on C#, if they haven't yet read a manual on it.

            When I first started with NinjaScript, some 8 months ago, I was somewhat lost on all the C# and .net ideosyncracies for a while, and it took me maybe a month to run across this one (String.Format instead of Variable.ToString() which really got tiresome after a while.) When I say I was a little lost, this is in spite of many years of programming in various other languages; I cannot imagine what it must be like for someone who has little or no experience when they're trying to pick up all these useful things that can be done in C#, but I suspect that little things like this might help. I think that adding more verbose and well-commented examples to the Help documentation would probably be a great assistance to any novice C# or NinjaScript programmer. I will try to add additional items to the forum to help on this, too, as they occur to me.

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Code:
              SendMail("[email protected]", "[email protected]", "Trade Alert", "Long strategy triggered on " + Instrument.MasterInstrument.Name + " in " + Bars.Period.Value + "-" + Bars.Period.Id + " time frame.");
              The body of your email would end up as something like this:
              "Long strategy triggered on ER2 in 1-Minute time frame."
              Hi Josh,how to add a time when alert is triggered?

              Comment


                #8
                Hello cachevery,

                Thank you for your post.

                The time would be added with Time[0]:
                Code:
                SendMail("[email protected]", "[email protected]", "Trade Alert", "Long strategy triggered on " + Instrument.MasterInstrument.Name + " in " + Bars.Period.Value + "-" + Bars.Period.Id + " time frame[B], at " +Time[0][/B]);

                Comment


                  #9
                  Originally posted by cachevery
                  Thank you Patrick,

                  Now can you please help me with the adding email alert for the two conditions.One which goes one tick above 1000>>>1001,and the other which goes below the constant >>>999.I`ve attached the code and the screenshot to better understand what i need.

                  Thanks in advance!
                  Maybe at least some steps to point out the right direction?

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello cachevery,

                    Thank you for your post.

                    The time would be added with Time[0]:
                    Code:
                    SendMail("[email protected]", "[email protected]", "Trade Alert", "Long strategy triggered on " + Instrument.MasterInstrument.Name + " in " + Bars.Period.Value + "-" + Bars.Period.Id + " time frame[B], at " +Time[0][/B]);
                    Hi Patrick,the method you`ve suggested the text message in the end with every alert looks like this:

                    "at 01.01.1800 0:00:00"

                    Comment


                      #11
                      Hello cachevery,

                      Thank you for your patience.

                      Can you provide the indicator file so I may test this item on my end? Where are you testing the indicator? On what instrument, period and interval?

                      I can also provide insight on your two conditions as well.

                      Comment


                        #12
                        Originally posted by NinjaTrader_PatrickH View Post
                        Hello cachevery,

                        Thank you for your patience.

                        Can you provide the indicator file so I may test this item on my end? Where are you testing the indicator? On what instrument, period and interval?

                        I can also provide insight on your two conditions as well.
                        Hi Patrick.

                        Here is the indicator.I use it with kagi bars on FDAX futs 60 seconds.
                        Attached Files

                        Comment


                          #13
                          Hello cachevery,

                          Where is the SendMail() method placed in the indicator?

                          Comment


                            #14
                            Hello cachevery,

                            Thank you for your response.

                            That is correct, but I need to know how you used it to get that result. Where was it placed when the time returned in such a manner?

                            Comment


                              #15
                              Hello cachevery,

                              Thank you for your response.

                              Where in the indicator's code did you place the SendMail() method? I am not looking for the syntax you are using at all, you have provided this several times already. I need to specifically know where you placed the SendMail() method in your indicator's code not what the SendMail() method looks like.

                              Alternatively you can provide the full indicator with the SendMail() in it so I can test on my end to see how you go the date of 01.01.1800 0:00:00.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X