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 overload and freeze

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

    SendMail overload and freeze

    Are there any solutions for mail being sent 100 times in 30 seconds when an entry is triggered?

    A working example would be terrific.

    Thanks.
    Last edited by brucelevy; 04-27-2016, 11:44 PM.

    #2
    Use a boolean type variable?

    Set it to TRUE or whatever when you send the email... and add this condition to your logic (don't send/enter position if true)...

    Comment


      #3
      just add 100 addresses in properties 100 times via comma

      Comment


        #4
        Hello brucelevy,

        Thanks for your post.

        As member sledge advised a bool variable in your condition can be used to limit the issuing of e-mails.

        if (your conditions to send mail && doItOnce)
        {
        SendMail(...);
        doItOnce = false; // set to false to prevent further e-mails
        }

        You would need to declare the variable doItOnce (or any name you prefer) as a private bool in the region variables. ex: private bool doItOnce = true; // start as true

        You would also need to determine a condition that you would use to reset the bool back to true so that it will send mail again when you want it to

        if (your conditions to reset the bool)
        {
        doItOnce = true; // reset so can send mail at next usage
        }
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by outsource View Post
          just add 100 addresses in properties 100 times via comma
          Sorry,i thought you wanted otherwise(to send 100 emails in 30 sec)

          this one should also work

          Code:
          private int				lastSignal  			= 0;
          
          if(sendEMail && lastSignal < CurrentBar)
          									
          					SendMail(email1, email2, "Trade Alert ", Time[0] + alertMessage);
          					lastSignal = CurrentBar;

          Comment


            #6
            What condition would be best to reset the bool? I am trying to understand how this works. Please let me know if this is correct:

            Once the execution is triggered, the bool becomes false.

            Then I need a condition to reset the bool from false to true.

            What would be the best way to reset it?
            Could I use:
            if (Position.MarketPosition == MarketPosition.Flat)
            {
            trigger = true;
            }


            Thanks
            Last edited by brucelevy; 04-30-2016, 10:51 PM.

            Comment


              #7
              Hello brucelevy,

              Thanks for your post.

              Yes, that would be one way to reset the bool.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                either too many emails per alert or reset function not working

                I am too also either getting several emails per single alert trigger or a lack of resetting issue once an alert triggers. any suggestions?

                Code:
                 public class AlertLines : Indicator
                    {
                        #region Variables
                			private Priority p = Priority.Medium;
                			private int alertpriority = 2;
                			private string alertName = "Alert1.wav";
                			private int rearmTime = 1;
                			private string aboveTagName = "above", belowTagName = "below";
                			private bool okToEmail = true; 
                        #endregion
                        protected override void Initialize()
                        {
                            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                            Overlay				= true;
                			CalculateOnBarClose = false;
                			switch(alertpriority)
                			{
                				case 1: p = Priority.Low; break;
                				case 2: p = Priority.Medium; break;
                				case 3: p = Priority.High; break;
                			}
                        }
                        protected override void OnBarUpdate()
                        {
                			if(!Historical)
                			{
                				foreach(IDrawObject draw in DrawObjects)
                				{
                					if(draw.UserDrawn == true && draw.DrawType == DrawType.Line)
                					{
                						ILine line = (ILine) draw;
                						double lineValue = Math.Max(line.StartY, line.EndY);
                						if(DateTime.Compare(Time[0], line.StartTime) >= 0 && DateTime.Compare(Time[0], line.EndTime) <= 0)
                						{
                							if(draw.Tag.ToLower().Contains(aboveTagName.ToLower()) && CrossAbove(Close, lineValue, 1))
                							{
                								Alert(draw.Tag, p, "Price Crossed Above " + draw.Tag, alertName, rearmTime, Color.White, Color.Black);
                							}
                							if(draw.Tag.ToLower().Contains(belowTagName.ToLower()) && CrossBelow(Close, lineValue, 1))
                							{
                								Alert(draw.Tag, p, "Price Crossed Below " + draw.Tag, alertName, rearmTime, Color.White, Color.Black);
                							}
                						}
                					}
                					else if(draw.UserDrawn == true && draw.DrawType == DrawType.HorizontalLine)
                					{
                						IHorizontalLine hline = (IHorizontalLine) draw;
                						double lineValue = hline.Y;
                						if(draw.Tag.ToLower().Contains(aboveTagName.ToLower()) && CrossAbove(Close, lineValue, 1)&& okToEmail)
                						{
                							Alert(draw.Tag, p, "Price Crossed Above " + draw.Tag, alertName, rearmTime, Color.White, Color.Black);
                							SendMail("@yahoo.com", "[email protected]", "RESISTANCE", "");
                							okToEmail = false;
                							
                						//if(draw.Tag.ToLower().Contains(aboveTagName.ToLower()) && Close[0]<= lineValue && okToEmail)
                							//{okToEmail = true;}
                						}
                						if(draw.Tag.ToLower().Contains(belowTagName.ToLower()) && CrossBelow(Close, lineValue, 1)&& okToEmail)
                						{
                							Alert(draw.Tag, p, "Price Crossed Below " + draw.Tag, alertName, rearmTime, Color.White, Color.Black);
                							SendMail("@yahoo.com", "[email protected]", "SUPPORT", "");
                							okToEmail = false;
                						//if(draw.Tag.ToLower().Contains(aboveTagName.ToLower()) && Close[0]>= lineValue && okToEmail)
                							//{okToEmail = true;}	
                						}
                						//ResetAlert("draw.Tag");
                						//ResetAlerts();
                					}
                				}
                			}
                			
                        }

                Comment


                  #9
                  Hello duck_CA,

                  Thanks for your post.

                  I recommend you debug your code with print statements so that you can see how often the sendMail() is getting hit and the state of bool OkToEmail.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Try this:

                    private int lastSignal = 0;

                    if(sendEMail && lastSignal < CurrentBar)
                    {
                    SendMail("@yahoo.com", "[email protected]", "SUPPORT", "");
                    lastSignal = CurrentBar;
                    }

                    Comment


                      #11
                      sendEMail is not working with N7

                      is this for N8?

                      Comment


                        #12
                        Originally posted by duck_CA View Post
                        sendEMail is not working with N7

                        is this for N8?
                        It worked for me as of last week in NT7 when my condition hit for a trade.

                        Comment


                          #13
                          haha, good to know it works for you.

                          hey can you take a look at the attached short video regarding the error message and chime in on what i'm missing?

                          thanks!
                          Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

                          Comment


                            #14
                            I think that explains it...sorry, I misunderstood -

                            I'm not using this magical "SendEMail" variable.. because - the "SendEMail" from OutSource appears to be short hand code for "Conditions that need to be true for an email to be sent", which you already have. His lastsignal < CurrentBar is his trick to help keep things under control.

                            Your original code with okToEmail looks good. It looks like you would only get 1 email - but no reset. When do you want this thing to reset?

                            You must be careful with how many emails you send - you'll get blocked and locked down because it looks like spam.

                            Comment


                              #15
                              Originally posted by sledge View Post
                              I think that explains it...sorry, I misunderstood -

                              I'm not using this magical "SendEMail" variable.. because - the "SendEMail" from OutSource appears to be short hand code for "Conditions that need to be true for an email to be sent", which you already have. His lastsignal < CurrentBar is his trick to help keep things under control.

                              Your original code with okToEmail looks good. It looks like you would only get 1 email - but no reset. When do you want this thing to reset?

                              You must be careful with how many emails you send - you'll get blocked and locked down because it looks like spam.
                              thanks for getting back so fast!

                              i'm just trying to get one email every 1 or 2 mins if those conditions keep firing off. currently it either fires off multiple emails that sends multiple texts which is annoying. just trying to slow it down.

                              the idea is to be alerted by text when i'm away from pc.

                              hope this helps!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              45 responses
                              3,992 views
                              3 likes
                              Last Post johntraderuser2  
                              Started by TAJTrades, Today, 09:46 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post TAJTrades  
                              Started by rhyminkevin, Yesterday, 04:58 PM
                              5 responses
                              62 views
                              0 likes
                              Last Post dp8282
                              by dp8282
                               
                              Started by realblubb, Today, 09:28 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post realblubb  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              1 response
                              19 views
                              0 likes
                              Last Post Rikazkhan007  
                              Working...
                              X