Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SendMail

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

    SendMail

    I'm trying to add a function for sending mail when there is a potential trade setup. The problem is that the script sending mail for (I guess) every tick, and I recive "tons" of emails. I need some help how to get this set to only send one mail when I have a potential setup. Below is the code I'm using right now. Hope someone can guide me in the right direction with this. Thanks

    if (mail==true && SMA1[0] > SMA2[0]
    {
    SendMail("[email protected]", [email protected], "Trade Alert", "Potential long @"+Instrument.FullName + Bars.Period.ToString() + " chart");

    mail = false;
    }

    #2
    finnbjurvoll, are you working with the script on CalculateOnBarClose = false then?

    If you are interested in the SMA crossover I would simply change the rule used to a CrossAbove / CrossBelow, so you would get a notification only on the crossover bar and not on subsequent bars as well until the opposite occurs.

    Comment


      #3
      SendMail

      I'm working on a CalculateOnBarClose = false.

      Ok, let me redefine.

      I guess the below code would be the same logic as crossAbove/Below?
      I still have the same problem. I can't use this based on bar close, I need to be alerted when there is a potential setup.

      Finn.

      if (mail==true && SMA1[1] < SMA2[1] && SMA1[0] > SMA2[0] && Rising(SMA3));
      {
      SendMail("[email protected]", address, "Trade Alert", "Potential long @"+BarsArray[0].Instrument.FullName+ Bars.Period.ToString() + " chart");
      mail = false;
      }

      Comment


        #4
        Thanks for the additional input, then I would suggest you add a bool flag to your code that you reset when you would like to trigger the alert again.

        Comment


          #5
          SendMail

          Thank you, that worked

          Comment


            #6
            Hi. Please could you put your code again based on NinjaTrader_Bertrand suggestion (adding a bool flag)? I have the same problem, and i would like to know how you fixed it.
            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            577 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 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
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X