Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SendMail - Multiple Notifications

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

    SendMail - Multiple Notifications

    I get several email notifications of the same event as the market "breathes" back and forth. If Calculate.OnPriceChange or Calculate.OneachTick is set to true. Calculate.OnBarClose doesn't generate this problem.

    In my case, whenever my strategy enters long or short, SendMail is activated; but I may get 10 emails for the same thing. Since only 1 entry per direction is allowed, I don't get several entries though! But how do I stop this? I need to calculate on Price change rather than on bar close and I'd like to receive the notice only once for every unique event.

    Many thanks.

    #2
    Hello aaadetos,

    Thanks for your post.

    In your code section that sends the mail you can add the action to save the current bar number into an integer variable (for example called savedBar). As part of the condition to send the e-mail you check to see if the current bar is not the same as the saved bar.

    if (your conditions && CurrentBar != savedBar)
    {
    sendMail(...);
    savedBar = CurrentBar; // save current bar number
    }

    The example would limit e-mail to once per bar.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul,
      But what if the condition changes and say fired long initially, then fires short before the bar was finished (say a 30-minute bar), the email will not send for the new event. Is there a way to capture the change in event even within the current bar? so long as it is unique and different? This could potentially happen, since it calculates on price change.

      Thank you.

      Comment


        #4
        Hello aaadetos,

        Thanks for your reply.

        Basically, you have the idea now to use a bool to control the e-mail. You can certainly use the same code block where you place your orders to also set the bool so that if you are long and then go short that the bool will also switch and allow the e-mail to occur. So you can still have the bool reset by a new bar and reset by a change in order direction.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X