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

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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 benmarkal, Yesterday, 12:52 PM
            3 responses
            23 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by helpwanted, Today, 03:06 AM
            1 response
            18 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            11 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            7 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            244 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Working...
            X